I have a problem using telebot API in python. If the user sends a message to the bot and waits for the response and at the same time he blocks the bot. I get this error and the bot will not respond for other users:
403,"description":"Forbidden: bot was blocked by the user
Try, catch block is not handling this error for me
any other idea to get rid of this situation? how to find out that the bot is blocked by the user and avoid replying to this message?
this is my code:
import telebot
import time
@tb.message_handler(func=lambda m: True)
def echo_all(message):
try:
time.sleep(20) # to make delay
ret_msg=tb.reply_to(message, "response message")
print(ret_msg)
assert ret_msg.content_type == 'text'
except TelegramResponseException as e:
print(e) # do not handle error #403
except Exception as e:
print(e) # do not handle error #403
except AssertionError:
print( "!!!!!!! user has been blocked !!!!!!!" ) # do not handle error #403
tb.polling(none_stop=True, timeout=123)
python-telegram-bot
tag, which is the tag for a different library. please tag the library that you're actually using ;) – Robinsonpy-telegram-bot-api
, which is the name of the library that provides thetelebot
module pypi.org/project/pyTelegramBotAPI. thepython-telegram-bot
is not a generic tag for telegram bots written in python but exclusively for the python library with the same name ;) – Robinson