zulip / python-zulip-api

Python library for the Zulip API.
https://zulip.com/api/
Apache License 2.0
350 stars 352 forks source link

`KeyError` when bridging Zulip to Element #754

Closed vigoux closed 2 years ago

vigoux commented 2 years ago

Hi, using the zulip api, I can't connect my zulip server to Matrix (element.org) because this raises an error.

I followed the steps described in the docs, and here is the error:

Starting matrix mirroring bot (this may take a minute)
Traceback (most recent call last):
  File "/<redacted>/python-zulip-api/zulip/integrations/bridge_with_matrix/matrix_bridge.py", line 333, in main
    matrix_login(matrix_client, matrix_config)
  File "/<redacted>/python-zulip-api/zulip/integrations/bridge_with_matrix/matrix_bridge.py", line 42, in matrix_login
    matrix_client.login_with_password(matrix_config["mxid"], matrix_config["password"])
  File "/<redacted>/python-zulip-api/zulip-api-py3-venv/lib/python3.10/site-packages/matrix_client/client.py", line 249, in login_with_password
    self._sync()
  File "/<redacted>/python-zulip-api/zulip-api-py3-venv/lib/python3.10/site-packages/matrix_client/client.py", line 551, in _sync
    for presence_update in response['presence']['events']:
KeyError: 'presence'
WARNING:zulip:Sleeping for 2s [max 2] before retrying.

Here is my matrix bridge config:

[matrix]
host = https://matrix.org
mxid = @nvimts-bot:matrix.org
password = <redacted>
room_id = #nvim-treesitter:matrix.org

[zulip]
email = nvim-treesitter-bridge-bot@zulipchat.com
api_key = <redacted>
site = https://nvim-treesitter.zulipchat.com
stream = general
topic = Gitter
rht commented 2 years ago

Sorry for the late response. Will be fixed in #755.

vigoux commented 2 years ago

Hi again, it looks like the bridge does not work though now. It does not send messages on the matrix side

rht commented 2 years ago

Note that the messages sent by the Matrix account used as the bridging bot won't be relayed over, because otherwise we will get infinite mirroring. You have to test sending from a different Matrix account. This fact probably needs to be documented.

vigoux commented 2 years ago

Yeah yeah I did not do that, using my own acount on both sides it does not go over

vigoux commented 2 years ago

It was an issue on my end, I forgot to subscribe the bot to the stream, sorry !