( offset: number, limit = 20, )
| 157 | * Uses long-poll with a short timeout so we don't block indefinitely. |
| 158 | */ |
| 159 | export async function getUpdates( |
| 160 | offset: number, |
| 161 | limit = 20, |
| 162 | ): Promise<TelegramUpdate[]> { |
| 163 | return tgApi<TelegramUpdate[]>(BOT_TOKEN!, "getUpdates", { |
| 164 | offset, |
| 165 | limit, |
| 166 | timeout: 5, |
| 167 | // Include both new messages and edits so we can observe streamed replies. |
| 168 | // The example bot streams by posting a placeholder and then editing it |
| 169 | // (chunked-edit mode), so we must subscribe to edited_message to see the |
| 170 | // final text. |
| 171 | allowed_updates: ["message", "edited_message"], |
| 172 | }); |
| 173 | } |
| 174 | |
| 175 | /** |
| 176 | * Drain any pending updates from the bot's queue (advances the offset without |
no test coverage detected