Git Product home page Git Product logo

nio-template's Issues

Bot re-execute all commands after re-joining the room

Hello,

We created a bot for a specific use-case, which is the following :

  1. User invite the bot to a room --> the bot auto-join
  2. The user ask the bot to send an mail to someone
  3. The bot is not needed any more , the user ask the bot to leave the room
  4. The user invite the bot to the room again (the user want to send another mail to someone)
  5. The bot Auto-join -> sync all room messages -> Re-execute all commands -> leave the room X(KO)

Any idea how to avoid re-executing the commands already existing in the room ?

Regards,

Timeout errors

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

Misleading in the way it fires `invite` events

The problem is this:

client.add_event_callback(callbacks.invite, (InviteMemberEvent,))

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.

Don't (try to) react to messages older than max(session creation, room join)

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.

ClientConnectionError

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 YAML config file reading

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.