Skip to content

Commit

Permalink
Merge pull request #864 from sigorilla/sigorilla.telegram-polling
Browse files Browse the repository at this point in the history
Does not work polling for Telegram bot
  • Loading branch information
chentsulin authored Oct 11, 2021
2 parents 56615d9 + 5f3b896 commit 8ffab7b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/bottender/src/telegram/TelegramBot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,18 @@ export default class TelegramBot extends Bot<
offset: this._offset,
}
: options;
const updates = await (this.connector as any).client.getUpdates(params);
// TODO: Remove casting after https://github.com/Yoctol/messaging-apis/issues/622
const updates = ((await this.connector.client.getUpdates(
params
)) as unknown) as TelegramRequestBody[];

if (updates.length > 0) {
for (let i = 0; i < updates.length; i++) {
await handler(updates[i]);
}

const highestUpdateId = Math.max(
...updates.map((update: any) => update.updateId)
...updates.map(update => update.updateId)
);

this._offset = highestUpdateId + 1;
Expand Down

0 comments on commit 8ffab7b

Please sign in to comment.