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

Direct message support for matrix (element) connector #1938

Open
m-yosefpor opened this issue Jul 5, 2022 · 3 comments
Open

Direct message support for matrix (element) connector #1938

m-yosefpor opened this issue Jul 5, 2022 · 3 comments

Comments

@m-yosefpor
Copy link

Description

Ability to handle direct messages in matrix. Users should be able to interact with bot in pv for matrix connector (other connectors such as slack and telegram already support this)

@diegodorgam
Copy link

diegodorgam commented Jul 28, 2022

Having trouble to receive the direct messages also.
Using docker image opsdroid/opsdroid:latest running opsdroid connected to my self hosted matrix server, with the configuration:

connectors:
  matrix:
    mxid: "@droid:chat.domain.com"
    password: "<REDACTED>"
    rooms:
      main: '#geral:chat.domain.com'
    homeserver: "https://chat.domain.com"
    nick: "Droid"
    room_specific_nicks: False  
    device_name: "opsdroid"
    enable_encryption: True
    device_id: "opsdroid" 
    store_path: "/home/opsdroid/store" 

I can receive and send messages from any public or private(not encrypted) room, but from DM generates this error:

droid       | Traceback (most recent call last):
droid       |   File "/usr/local/lib/python3.9/site-packages/opsdroid/connector/matrix/connector.py", line 319, in _parse_sync_response
droid       |     event = self.connection.decrypt_event(event)
droid       |   File "/usr/local/lib/python3.9/site-packages/nio/client/base_client.py", line 115, in inner
droid       |     return fn(self, *args, **kwargs)
droid       |   File "/usr/local/lib/python3.9/site-packages/nio/client/base_client.py", line 641, in decrypt_event
droid       |     return self.olm.decrypt_megolm_event(event)
droid       |   File "/usr/local/lib/python3.9/site-packages/nio/crypto/olm_machine.py", line 1525, in decrypt_megolm_event
droid       |     raise EncryptionError(message)
droid       | nio.exceptions.EncryptionError: Error decrypting megolm event, no session found with session id PVa5IgZQa4eIIR+UXtttgNq3c23JTIQlEBCtset2DKs for room !FxdJJEGABYMhOhgVKt:chat.domain.com

Any ideas on how to solve it?

@Cadair
Copy link
Contributor

Cadair commented Mar 8, 2023

The matrix connector as currently implemented should be perfectly capable of processing messages in DMs. It will respond to any event in any room (DMs are just rooms with two people) it is in. If you want the bot to automatically join rooms it's invited to you need to do something like this:

    @match_event(UserInvite)
    async def on_invite_to_room(self, invite):
        """
        Join all rooms on invite.
        """
        await invite.respond(JoinRoom())

in you skill.

@diegodorgam Your issue is an encryption issue, I think it would be better if you opened a new issue if you are still having trouble.

@x-c4mp3r
Copy link

x-c4mp3r commented Oct 9, 2023

@Cadair I copied your solution but I couldn't figure out why it's not working. Here is my code:
skill/automatisms/init.py

import logging

from opsdroid.connector import register_event
from opsdroid import const, events
from opsdroid.matchers import match_event
from opsdroid.skill import Skill


class AutomatismsSkill(Skill):

    def __init__(self, opsdroid, config, *args, **kwargs):
        super().__init__(opsdroid, config, *args, **kwargs)
        self.name = "Automatisms"

    @match_event(events.UserInvite)
    async def invitation_on_something(self, invite):
        logging.info(f"Join all rooms on invite {invite.target}.")
        await invite.respond(events.JoinRoom())

configuration/configuration.yaml

...
skills:
  automatisms:
    path: /skill/automatisms/
...

I also copied this from you: https://github.com/Cadair/skill-jitsi/blob/d0af91ad921b8123272ccccdff90260d62034ed4/__init__.py#L249-L257 but it's the same, not working.
Could you help me?
I using matrix connector and the opsdroid source code is three weeks old

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

No branches or pull requests

5 participants