Achaak / toogoodtogo-bot

TooGooToGo-Bot is a tool designed to help you stay informed about the availability of your favorite stores on the Too Good To Go platform. It sends notifications, allowing you to quickly find and purchase food products before they disappear.
MIT License
59 stars 17 forks source link

"Bot was blocked by user" #27

Open BoredinBerlin opened 3 months ago

BoredinBerlin commented 3 months ago

Started seeing these errors today -- not sure what it means exactly....I seem to be getting these alerts, just never noticed this behaviour before. Is it something on Telegram's end?

TelegramError: 403: Forbidden: bot was blocked by the user at Telegram.callApi (/Users/xxxxx/xxxx/toogoodtogo-bot/node_modules/.pnpm/telegraf@4.15.3/node_modules/telegraf/lib/core/network/client.js:302:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { response: { ok: false, error_code: 403, description: 'Forbidden: bot was blocked by the user' }, on: { method: 'sendMessage', payload: { chat_id: 1297094036, parse_mode: 'HTML', text: 'Original Unverpackt\nAvailable: 1\n3,00 €\nToday 19:15 - 19:45' } } }

stefanodelbosco commented 2 months ago

Hello, 403 this error is when your script send a message to a user that delete and block the bot.

The chat_id indicated in the error message is the user

I hope, it can help you 😁

BoredinBerlin commented 2 months ago

How can I tell what user that is by the chat_id? Is there some way to see that in Telegram?

stefanodelbosco commented 2 months ago

I don't think there is a way to get this info.. Reading the code, i see the file where the 'chat_id' are stored after the '/start' command.

const file = path.join(__dirname, '..', '..', 'store', 'data.json');

I think you can:

I think with this steps it will be fix the problem (the bot will restart without knowing the previous chat_id) :)

In this program you cannot set an 'admin chat_id' to filter the casual people when they 'start' the bot randomally.