anoadragon453 / nio-template Goto Github PK
View Code? Open in Web Editor NEWA template for creating matrix bots in python with matrix-nio
License: Apache License 2.0
A template for creating matrix bots in python with matrix-nio
License: Apache License 2.0
Hello,
We created a bot for a specific use-case, which is the following :
Any idea how to avoid re-executing the commands already existing in the room ?
Regards,
Just need to finish it up.
I think this would be a good idea to handle in the main template, and shouldn't it to just try to reconnect rather than die completely?
Traceback (most recent call last):
File "main.py", line 98, in <module>
asyncio.get_event_loop().run_until_complete(main())
File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
File "main.py", line 86, in main
await client.sync_forever(timeout=30000, full_state=True)
File "/home/sm/Github/dankbot/venv/lib/python3.7/site-packages/nio/client/async_client.py", line 1147, in sync_forever
await self.run_response_callbacks([await response])
File "/usr/lib/python3.7/asyncio/tasks.py", line 533, in _wait_for_one
return f.result() # May raise f.exception().
File "/home/sm/Github/dankbot/venv/lib/python3.7/site-packages/nio/client/async_client.py", line 1003, in sync
timeout,
File "/home/sm/Github/dankbot/venv/lib/python3.7/site-packages/nio/client/async_client.py", line 705, in _send
method, path, data, headers, trace_context, timeout,
File "/home/sm/Github/dankbot/venv/lib/python3.7/site-packages/nio/client/async_client.py", line 252, in wrapper
return await func(self, *args, **kwargs)
File "/home/sm/Github/dankbot/venv/lib/python3.7/site-packages/nio/client/async_client.py", line 781, in send
else timeout,
File "/home/sm/Github/dankbot/venv/lib/python3.7/site-packages/aiohttp/client.py", line 544, in _request
await resp.start(conn)
File "/home/sm/Github/dankbot/venv/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 905, in start
self._continue = None
File "/home/sm/Github/dankbot/venv/lib/python3.7/site-packages/aiohttp/helpers.py", line 656, in __exit__
raise asyncio.TimeoutError from None
concurrent.futures._base.TimeoutError
I am using the loop as in the template code and it looks like it syncs to often.
My homeserver log is filled with messages like:
https://framabin.org/p/?ee3f825e469d12c8#B6hNNDtYf8AafS0Yy+hcy/wCHS5bPogwKweSbQ5wZIs=
The problem is this:
nio-template/my_project_name/main.py
Line 66 in c7752db
InviteMemberEvent
is a bit of a misnomer. It's not an event meaning the bot was invited; it's an event meaning that the bot received a piece of m.room.member
state in the rooms.invite
section of a sync response.
Sure, this means the bot had to be newly invited to that room, but the homeserver might also send the m.room.member
state for other members (crucially, it'd make sense if the inviter is included at a minimum, because graphical clients display the name and avatar of the person inviting you).
What needs to be checked is that the state event has a state key matching the bot's user ID (otherwise it's someone else's state event!). Otherwise, we will process one invite multiple times.
Same issue as anoadragon453/matrix-reminder-bot#86.
Workaround is to update your version of matrix-nio
to v0.18.0+.
A new release coming soon to address this.
Bots, in this instance matrix-reminder-bot, otherwise try to react to events they aren't supposed to read. Nobody would expect a bot to react to commands from before its time. Particularly that prevents lots of decryption errors.
It should also not try to react to itself, e.g. its own error messages when resetting the session.
Because who knows how to build libolm from source amirite
https://spec.matrix.org/v1.1/client-server-api/#user-room-and-group-mentions
there are
<p>
in the formatted_body and html in the regular body.
Encourage people to write tests for the projects they make.
Login will fail with the following if python-nio
python bindings are not installed in the python environment:
2020-04-06 22:30:29,903 | __main__ [CRITICAL] Error logging in: No store class was provided in the config.
Does matrix-nio need the store put in a different spot depending on whether python bindings are installed?
Hi everyone, just trying out this project. I tried it a few month ago, and had the initial bot running and answering to messages, but had no time to continue, now I started again.
Set up the config.yaml and tried the dev-Docker way. The container builds just fine, but now I am stuck with a ClientConnectionError and cannot get a grasp at the problem.
The log states:
[WARNING] Cannot connect to host matrix.org:443 ssl:default [Try again]
[WARNING] Unable to connect to homeserver, retrying in 15s...
and that's just it (the first warning is the ClientConnectionError as e). He tries again forever. Does someone else got this problem, too?
I tried to add curl to the container and can connect to the url just fine - so it does not seem like a connection error. But neither a login error, as this would raise a different error. I even tried updating to >0.18 of matrix-neo like suggested in the issue with a newer synapse version. But no luck at all.
Any ideas on this, what am I missing. Any help or hints would be appreciated :).
Factor out the helper function into a new ConfigFile
class, which you instantiated with a config file path, and has a function to get a value from it.
This will be useful to people trying to load other yaml files for configuration reasons, without complicating the template too much.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.