-
-
Notifications
You must be signed in to change notification settings - Fork 0
Matrix
so the bridge supports multiple authorization methods, user bot and an oauth token. I choose to use a bot account, so the bot status can reflect the bridge's status. If the bridge is down, the bot will be too.
Create a bot on https://discord.com/developers/applications
just create a new “application”, fill some details and head down to the bot section. Enable all permissions under the Privileged Gateway Intents section. Turn public bot off, it's only meant for Aosus.
Adding a bot to a discord server is a bit complex.
Copy the Application ID listed in the General Information page.
And then use this link with the Bot's ID
https://discord.com/api/oauth2/authorize?client_id=xxxxx&permissions=0&scope=bot
this bridge is mainly to be used as a puppeting bridge. After setting up a room bridge "!discord bridge " (room ID can be copied from the URL, or there should be a copy ID option if you enabled discords dev mode).
And now let's create the relay
!discord set-relay --create <name>
from the aosus admin account create a new direct chat with the bot and write login-token bot <token>
the token should be in the bot section.
this doesn't seem to work normally bridges just re-upload content to matrix for bridging. However, this massively increases storage costs, and should be avoided as much as possible. Luckily it's avoidable in the discord bridge.
Since the CDN links for discord images is public, we can just directly load images from it. It's not very simple, but through a trick explained here, a few Caddy settings to proxy images from discord are enough.
Yes It's still going to cost us bandwidth, but most importantly no storage costs. Besides when bandwidth gets expensive for some reason, we can do it on the Cloudflare level, however the entire Matrix server needs to be behind Cloudflare for it to work.
To prevent spoofing by using multiple servers or changing used names.
We will expose the full MXID, so it can't be faked.
Here is the command used in the room to use MXIDs along with display names, to prevent impersonation, and still make it easy to identify cross-platform users.
!tg config set message_formats m.text: "<pre>$sender_displayname/$sender_mxid</pre> $message"
m.file: "<pre>$sender_displayname/$sender_mxid:</pre> ارسل ملف $message"
m.image: "<pre>$sender_displayname/$sender_mxid:</pre> ارسل صورة: $message"
m.audio: "<pre>$sender_displayname/$sender_mxid</pre> ارسل ملف صوتي: $message"
m.video: "<pre>$sender_displayname/$sender_mxid</pre> ارسل مقطع مرئي: $message"
m.location: "<pre>$sender_displayname/$sender_mxid</pre> ارسل موقع جيوغرافي: $message"
m.notice: "<pre>$sender_displayname/$sender_mxid</pre>: $message"
m.emote: "* <pre>$sender_displayname/$sender_mxid</pre> $message"
These are annoying in public groups and are being hidden in the telegram chat.
To mute these events from being forwarded.
!tg config set state_event_formats join: ""
leave: ""
name_change: ""