I’m building a telegram bot using pyTelegramBotAPI libraries, I wanted to know if there is a way to know when a user deletes a chat with my bot, so the bot will not send more messages towards that specific id.
reading the telegram API I found nothing, can you help me?
Question posted in Telegram API
A comprehensive official documentation can be found here.
A comprehensive official documentation can be found here.
2
Answers
EDIT: Bot API 5.1 introduces a new update type represented by ChatMemberUpdated class.
When a user blocks your bot you will now receive an update looking like this:
Handle this update accordingly. It has all relevant information to let you exclude a user, who has blocked your bot.
Old answer:
Sadly you can’t know when a user has deleted a chat with your bot.
You can keep sending messages though. Eventually the user will block your bot.
Trying to send a message to a user who has blocked your bot will give you HTTP status code error 403.
Only then you can safely delete a user’s chat_id from your list.