hopfenspace / MateBot

Micro service providing an API for MateBot clients

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bot breaks if a management message has not been modified for subcommand "show"

CrsiX opened this issue · comments

commented

Using /pay show or /communism show in a chat that already has an active collective of the specified user that has not been modified using votes or joined users, yields the following traceback:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/telegram/ext/dispatcher.py", line 340, in process_update
    handler.handle_update(update, self, check, context)
  File "/usr/local/lib/python3.7/dist-packages/telegram/ext/handler.py", line 119, in handle_update
    return self.callback(update, context)
  File "/home/matebot/MateBot/mate_bot/commands/base.py", line 211, in __call__
    self.run(args, update)
  File "/home/matebot/MateBot/mate_bot/commands/pay.py", line 76, in run
    collective.show(update.effective_message)
  File "/home/matebot/MateBot/mate_bot/collectives/communism.py", line 164, in show
    message.bot
  File "/home/matebot/MateBot/mate_bot/collectives/base.py", line 547, in edit_all_messages
    parse_mode=parse_mode
  File "<decorator-gen-27>", line 2, in edit_message_text
  File "/usr/local/lib/python3.7/dist-packages/telegram/bot.py", line 67, in decorator
    result = func(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/telegram/bot.py", line 1898, in edit_message_text
    return self._message(url, data, timeout=timeout, reply_markup=reply_markup, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/telegram/bot.py", line 175, in _message
    result = self._request.post(url, data, timeout=timeout)
  File "/usr/local/lib/python3.7/dist-packages/telegram/utils/request.py", line 333, in post
    **urlopen_kwargs)
  File "/usr/local/lib/python3.7/dist-packages/telegram/utils/request.py", line 244, in _request_wrapper
    raise BadRequest(message)
telegram.error.BadRequest: Message is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the message
commented

This error happens due to the call of edit_all_messages and is caused by attempting to edit the management message in another chat. But as it's not necessary to edit the message in this other chat, the exception can be ignored. Doing so will not change the messages in the other chats. However, the message in the current chat will be shown correctly because it was edited previously.