matrix-discord-bridge icon indicating copy to clipboard operation
matrix-discord-bridge copied to clipboard

Bridge.py only works in one direction

Open Akselmo opened this issue 2 years ago • 11 comments

The messages come from discord to matrix, but not from matrix to discord

Logs

2022-07-02 21:05:21 discord.client:WARNING: PyNaCl is not installed, voice will NOT be supported
2022-07-02 21:05:21 discord.client:INFO: logging in using static token
2022-07-02 21:05:22 matrix_logger:INFO: Logged in as @matrix-discord-bridge:matrix.akselmo.dev, device id: GGEJQJXCIQ.
2022-07-02 21:05:22 matrix_logger:INFO: Clients ready!
2022-07-02 21:05:22 discord.gateway:INFO: Shard ID None has sent the IDENTIFY payload.
2022-07-02 21:05:22 discord.gateway:INFO: Shard ID None has connected to Gateway: ["gateway-prd-main-456x",{"micros":81093,"calls":["discord-sessions-green-prd-2-200",{"micros":79640,"calls":["start_session",{"micros":38729,"calls":["discord-api-f8857dbfb-dkkhc",{"micros":34594,"calls":["get_user",{"micros":8979},"add_authorized_ip",{"micros":1664},"get_guilds",{"micros":3365},"coros_wait",{"micros":2}]}]},"guilds_connect",{"micros":2,"calls":[]},"presence_connect",{"micros":23745,"calls":[]}]}]}] (Session ID: bb52c75524c62fca0b720dafd94b901d).

Akselmo avatar Jul 02 '22 18:07 Akselmo

I have had this problem before too. For me clearing pycache and then waiting sometimes longer than 10 minutes from restarting the bot fixed it

Cknight70 avatar Jul 02 '22 18:07 Cknight70

Waiting hasnt worked for me.. And to clarify i meant the non-appservice bridge. The appservice one refuses to work for me at all.

Akselmo avatar Jul 02 '22 21:07 Akselmo

I have the same problem. Did you find the solution?

mayman007 avatar Aug 17 '22 18:08 mayman007

I have the same problem. Did you find the solution?

Unfortunately not. I just went with this instead: https://github.com/matrix-org/matrix-appservice-discord

Akselmo avatar Aug 17 '22 19:08 Akselmo

Also having this issue

nfacha avatar Sep 23 '22 13:09 nfacha

Also having this issue

Can you share your bridge config?

Unfortunately I don't use discord anymore so won't be able to debug the issue, the accounts keep getting disabled with phone verification popup. You could try adding debug prints in the message received callbacks and see.

git-bruh avatar Sep 23 '22 13:09 git-bruh

the accounts keep getting disabled with phone verification popup

Eh, just to confirm, this is a BOT account token, not a USER account token right? If so that popup doesn't make sense at all

{
    "homeserver": "https://matrix.facha.dev",
    "username": "@neo:facha.dev",
    "password": "XXX",
    "token": "XXX",
    "discord_cmd_prefix": "**",
    "bridge": {
        "412668210853183516": "!dMlxDKlOrpNuCzbfzC:facha.dev"
    }
}

XXX = PLACEHOLDER

nfacha avatar Sep 23 '22 15:09 nfacha

Yeah it's a bot token. I meant that discord disables your account during the sign up process itself before you can get to the developer portal thingy.

My current setup has been using the appservice bridge for around a year now and still works fine on a bot token created from an account which got deactivated in this manner (they don't deactivate bots). You could try that one since you have a self hosted server, has much better QOL too with proper dummy users instead of plaintext bridging, and infinitely better code quality

I'm looking into this issue, seems like the bot isn't able to get the channels for some reason, perhaps something to do with an intents change

git-bruh avatar Sep 23 '22 18:09 git-bruh

Nvm, it still works OK. I had messed up in the dev panel and didn't even have the bot in the server. Do you mind sharing the scopes you requested for the bot? I made mine an Administrator, you probably just need the webhook permissions though.

Screenshot_20220924-004643_Chromium Screenshot_20220924-004648_Element

git-bruh avatar Sep 23 '22 19:09 git-bruh

Nvm, it still works OK. I had messed up in the dev panel and didn't even have the bot in the server. Do you mind sharing the scopes you requested for the bot? I made mine an Administrator, you probably just need the webhook permissions though.

Screenshot_20220924-004643_Chromium Screenshot_20220924-004648_Element

Now I'm getting an error too on Discord > Matrix

root@matrix-bridge:~/matrix-discord-bridge/bridge# python3 bridge.py 
2022-09-26 14:09:27 discord.client:WARNING: PyNaCl is not installed, voice will NOT be supported
2022-09-26 14:09:27 discord.client:INFO: logging in using static token
2022-09-26 14:09:28 matrix_logger:INFO: Logged in as @neo:facha.dev, device id: QKYEPDZJDO.
2022-09-26 14:09:28 matrix_logger:INFO: Clients ready!
2022-09-26 14:09:28 discord.gateway:INFO: Shard ID None has sent the IDENTIFY payload.
2022-09-26 14:09:28 discord.gateway:INFO: Shard ID None has connected to Gateway: ["gateway-prd-us-east1-c-7cq2",{"micros":141600,"calls":["id_created",{"micros":1363,"calls":[]},"session_lookup_time",{"micros":6909,"calls":[]},"session_lookup_finished",{"micros":13,"calls":[]},"discord-sessions-blue-prd-2-8",{"micros":133046,"calls":["start_session",{"micros":72071,"calls":["discord-api-bf7497dbf-dkqk8",{"micros":63680,"calls":["get_user",{"micros":13837},"get_guilds",{"micros":7927},"send_scheduled_deletion_message",{"micros":11},"guild_join_requests",{"micros":2847},"authorized_ip_coro",{"micros":9}]}]},"starting_guild_connect",{"micros":52,"calls":[]},"presence_started",{"micros":40330,"calls":[]},"guilds_started",{"micros":87,"calls":[]},"guilds_connect",{"micros":1,"calls":[]},"presence_connect",{"micros":20462,"calls":[]},"connect_finished",{"micros":20467,"calls":[]},"build_ready",{"micros":19,"calls":[]},"optimize_ready",{"micros":1,"calls":[]},"split_ready",{"micros":0,"calls":[]},"clean_ready",{"micros":18,"calls":[]}]}]}] (Session ID: d914ed85b62613dc3ef56918a9d38bb5).
Ignoring exception in on_message
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "/root/matrix-discord-bridge/bridge/bridge.py", line 281, in on_message
    matrix_message = await self.matrix_client.message_send(
  File "/root/matrix-discord-bridge/bridge/bridge.py", line 189, in message_send
    return message.event_id
AttributeError: 'RoomSendError' object has no attribute 'event_id'

nfacha avatar Sep 26 '22 14:09 nfacha

The message is failing to send, as I said the non-appservice bridge code is not so good so it doesn't have good error reporting.

Is the bot account invited and joined in the matrix room and are you able to send messages through that account via element?

git-bruh avatar Sep 26 '22 14:09 git-bruh