This is an additional implementation compared to the telebot module. This module is designed for quick initialization, authorization and rendering of various buttons/widgets for telegram bots.
MIT License
0
stars
0
forks
source link
Bug: Attempting to delete a message that does not exist causes the bot to crash #43
Choose the component of the module where the bug is located
[x] Basic functions of the module
Describe the bug
Attempting to delete a message that does not exist causes the bot to crash.
Error message:
[2024-08-25 08:44:44,334] ERROR [logger.logger:handle:27] [Bot]: Error: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: message to delete not found
Exception in thread WorkerThread2:
Traceback (most recent call last):
File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/telebot/util.py", line 93, in run
task(*args, **kwargs)
File "/home/pyinstabot-downloader/app/src/bot.py", line 408, in process_one_post
telegram.delete_message(message.chat.id, message.id)
File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/telegram/telegram.py", line 234, in delete_message
self.telegram_bot.delete_message(
File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/telebot/__init__.py", line 1950, in delete_message
return apihelper.delete_message(self.token, chat_id, message_id, timeout=timeout)
File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/telebot/apihelper.py", line 1515, in delete_message
return _make_request(token, method_url, params=payload, method='post')
File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/telebot/apihelper.py", line 168, in _make_request
json_result = _check_result(method_name, result)
File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/telebot/apihelper.py", line 195, in _check_result
raise ApiTelegramException(method_name, result, result_json)
telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: message to delete not found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/threading.py", line 980, in _bootstrap_inner
self.run()
File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/telebot/util.py", line 103, in run
self.exception_callback(self, self.exception_info)
File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/telebot/util.py", line 140, in on_exception
handled = self.telebot.exception_handler.handle(exc_info)
File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/telegram/telegram.py", line 28, in handle
raise FailedToCreateInstance("Failed to create the bot instance.") from exception
telegram.exceptions.FailedToCreateInstance: Failed to create the bot instance.
Additional context
I think that such behavior should not cause the whole instance to crash, it will be enough to limit it to an error message in the log.
Choose the component of the module where the bug is located
Describe the bug Attempting to delete a message that does not exist causes the bot to crash. Error message:
Additional context I think that such behavior should not cause the whole instance to crash, it will be enough to limit it to an error message in the log.
Possible correction Add
try/except
in method https://github.com/obervinov/telegram-package/blob/v2.0.0/telegram/telegram.py#L225-L240Screenshots None
Check list after fixing the bug None