moan0s / matrix-registration-bot

A bot that is used to create and manage registration tokens for a matrix server
GNU Affero General Public License v3.0
64 stars 10 forks source link

Bot crashes when attempting to invite #27

Closed prurigro closed 1 year ago

prurigro commented 1 year ago

Hey, first I want to say thanks for this project- it's made delegating invites on my server much nicer :).

I've been running 1.1.5 successfully for nearly a year now, but python recently updated and I had to reinstall the bot. I ended up with 1.2.2 (according to __init__.py), and tried starting it up but ran into https://github.com/moan0s/matrix-registration-bot/issues/23 (I'm using a virtualenv, not docker). So I switched to using the access token and it started up successfully, but it wouldn't respond to any messages, so I left the channel and recreated it, but now it crashes whenever I try to invite the bot. I tried reverting to 1.1.5 and have the same problem there, so I assume it's either something that changed with synapse or (most likely based on the log) either python or a dependency.

Here's the log:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/matrix_registration_bot/bot.py", line 203, in <module>
    run_bot()
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/matrix_registration_bot/bot.py", line 195, in run_bot
    bot.run()
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/simplematrixbotlib/bot.py", line 88, in run
    asyncio.run(self.main())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/simplematrixbotlib/bot.py", line 81, in main
    await self.async_client.sync_forever(timeout=3000, full_state=True)
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/nio/client/async_client.py", line 1199, in sync_forever
    await self.run_response_callbacks([await response])
                                       ^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/tasks.py", line 605, in _wait_for_one
    return f.result()  # May raise f.exception().
           ^^^^^^^^^^
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/nio/client/async_client.py", line 1046, in sync
    response = await self._send(
               ^^^^^^^^^^^^^^^^^
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/nio/client/async_client.py", line 792, in _send
    await self.receive_response(resp)
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/nio/client/async_client.py", line 704, in receive_response
    await self._handle_sync(response)
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/nio/client/async_client.py", line 669, in _handle_sync
    await self._handle_invited_rooms(response)
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/nio/client/async_client.py", line 576, in _handle_invited_rooms
    await asyncio.coroutine(cb.func)(room, event)
          ^^^^^^^^^^^^^^^^^
AttributeError: module 'asyncio' has no attribute 'coroutine'. Did you mean: 'coroutines'?
2023-05-30 20:58:29,269 ERROR:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f119c045010>
2023-05-30 20:58:29,270 ERROR:Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7f119c1fd5c0>, 15377.595381204)]']
connector: <aiohttp.connector.TCPConnector object at 0x7f119c044410>

Thanks!

moan0s commented 1 year ago

Thanks for the report I'll be looking into that.

Edit: I could reproduce the error 🥳

moan0s commented 1 year ago

You where right: It is a dependency/python version issue! The problem is, that matrix-nio < 0.20.1 is not compatible with python 3.11 and simplematrixbotlib currently forces matrix-nio==0.19. I opend a issue in the simplematrixbotlib repository and will open a PR so hopfully this is fixed quickly https://codeberg.org/imbev/simplematrixbotlib/issues/39

prurigro commented 1 year ago

Awesome, thanks for tracking down the issue and getting a fix in the pipeline. It looks like the maintainer has already responded :)

moan0s commented 1 year ago

Just an update: While we wait for the dependency you can already fix this with

prurigro commented 1 year ago

Looks like things are good now! Thanks!