one-zero-eight / sport-bot

Track sports progress and check-in for classes via Telegram.
https://t.me/IUSportBot
MIT License
5 stars 0 forks source link

The bot crashes while trying to send a message to user who blocked the bot #40

Closed ArtemSBulgakov closed 5 months ago

ArtemSBulgakov commented 6 months ago

Describe the bug

When a user has blocked the bot, and the bot wants to send some message, it crashes the whole bot process. Then it restarts

Reproduction

I have not tested these steps, but I think it could be reproduced so:

  1. Stop bot for some time.
  2. Send /menu to bot.
  3. Block the bot in telegram.
  4. Restart the bot and let it process the missed message.
  5. The process crashes with error.

Screenshots / Additional context

The log: ` bot-1 | 2024-05-16T18:45:51.564272736+03:00 /app/node_modules/.pnpm/grammy@1.22.4/node_modules/grammy/out/core/error.js:35 bot-1 | 2024-05-16T18:45:51.564329936+03:00 return new GrammyError(Call to '${method}' failed!, err, method, payload); bot-1 | 2024-05-16T18:45:51.564341236+03:00 ^ bot-1 | 2024-05-16T18:45:51.564343636+03:00 bot-1 | 2024-05-16T18:45:51.564345736+03:00 GrammyError: Call to 'sendChatAction' failed! (403: Forbidden: bot was blocked by the user) bot-1 | 2024-05-16T18:45:51.564347536+03:00 at toGrammyError (/app/node_modules/.pnpm/grammy@1.22.4/node_modules/grammy/out/core/error.js:35:12) bot-1 | 2024-05-16T18:45:51.564349636+03:00 at ApiClient.callApi (/app/node_modules/.pnpm/grammy@1.22.4/node_modules/grammy/out/core/client.js:90:48) bot-1 | 2024-05-16T18:45:51.564351836+03:00 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { bot-1 | 2024-05-16T18:45:51.564365736+03:00 method: 'sendChatAction', bot-1 | 2024-05-16T18:45:51.564368036+03:00 payload: { bot-1 | 2024-05-16T18:45:51.564370136+03:00 chat_id: 1832702045, bot-1 | 2024-05-16T18:45:51.564372136+03:00 action: 'typing', bot-1 | 2024-05-16T18:45:51.564374436+03:00 business_connection_id: undefined bot-1 | 2024-05-16T18:45:51.564376536+03:00 }, bot-1 | 2024-05-16T18:45:51.564378536+03:00 ok: false, bot-1 | 2024-05-16T18:45:51.564380536+03:00 error_code: 403, bot-1 | 2024-05-16T18:45:51.564382836+03:00 description: 'Forbidden: bot was blocked by the user', bot-1 | 2024-05-16T18:45:51.564384936+03:00 parameters: {} bot-1 | 2024-05-16T18:45:51.564387236+03:00 } bot-1 | 2024-05-16T18:45:51.564389036+03:00 bot-1 | 2024-05-16T18:45:51.564391236+03:00 Node.js v18.20.2 bot-1 | 2024-05-16T18:45:53.364539146+03:00  ELIFECYCLE  Command failed with exit code 1. `