Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'body' in mcommand_handler.py #23

Open
vranki opened this issue Jun 23, 2019 · 0 comments
Open

KeyError: 'body' in mcommand_handler.py #23

vranki opened this issue Jun 23, 2019 · 0 comments

Comments

@vranki
Copy link

vranki commented Jun 23, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant