1

我正在使用 Vue 应用程序中的 mtproto-core ( https://github.com/alik0211/mtproto-core ) 与 Telegram API 进行交互。

一切正常,除了当我尝试获取更新时,我按照示例代码进行操作,但它不起作用。

任何帮助将不胜感激。

mtproto.updates.on('updateShort', message => {
  const { update } = message;

  if (update._ === 'updateUserStatus') {
    const { user_id, status } = update;

    console.log(`User with id ${user_id} change status to ${status}`);
  }
});
4

1 回答 1

1

遗憾的是,如果您想接收更新,则必须每隔 n 秒轮询一次 updates.getState。

所以是这样的:

setInterval(() => mtproto.call('updates.getState', {}), 3000)
于 2021-04-02T11:35:19.683 回答