python-matrix-bot-api icon indicating copy to clipboard operation
python-matrix-bot-api copied to clipboard

KeyError: 'body' in mcommand_handler.py

Open vranki opened this issue 5 years ago • 0 comments

My bot crashed with this stack trace:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/matrix_client/client.py", line 473, in listen_forever
    self._sync(timeout_ms)
  File "/usr/local/lib/python3.7/site-packages/matrix_client/client.py", line 585, in _sync
    room._put_event(event)
  File "/usr/local/lib/python3.7/site-packages/matrix_client/room.py", line 308, in _put_event
    listener['callback'](self, event)
  File "/bot/matrix_bot_api/matrix_bot_api.py", line 58, in handle_message
    if handler.test_callback(room, event):
  File "/bot/matrix_bot_api/mcommand_handler.py", line 23, in test_command
    if re.match(self.cmd_char + self.command, event['content']['body']):
KeyError: 'body'

I'm not sure what the situation is when a m.room.message does not have a body. Maybe related to some new feature such as edits or aggregations?

I suppose a check is needed if the message has body to avoid this exception.

vranki avatar Jun 23 '19 13:06 vranki