···1313- XMPP Avatar spoofing on the Discord side
1414- Support for proxying media sent via Discord (With [this miniproxy](https://git.polynom.me/PapaTutuWawa/miniproxy))
15151616-## Usage
1616+## Install
17171818-The bridge can be configured via `config.toml` at either the current working directory or `/etc/xmpp-discord-bridge/config.toml`.
1818+⚠️ This is how I set it up on Debian Bookworm. If you need help adapting it to your distribution, please open an issue or ask for help on [Jabber](xmpp:bridging@joinjabber.org?join).
1919+2020+⚠️ This guide also does not use a "venv" (virtual environment). I had an issue running it in its own "venv". If someone wants to troubleshoot it, contributions are welcome.
19212020-```toml
2121-[general]
2222-jid = "discord.server.example" # JID of the server component
2323-secret = "secret" # Component secret
2424-server = "server.example" # Address of the actual XMPP server
2525-port = 5869 # Component port
2626-discord_token "...." # Token of your Discord bot
2222+1. Install needed dependencies. `sudo apt install git python3-full pip cmake`
2323+2. Create a new system user to run it under. `sudo adduser --system --home /var/lib/xmpp-discord-bridge xmpp-discord-bridge`
2424+3. Now open a shell as that user. `sudo -u xmpp-discord-bridge -s`
2525+4. Run: `cd && git clone "https://codeberg.org/queer-spark/xmpp-discord-bridge.git" && cd xmpp-discord-bridge && python3 -m pip install . --user --break-system-packages && cd`
2626+5. Create and edit `~/config.toml`. Refer to [example.toml](example.toml) for options.
2727+6. `exit` to leave the shell.
2828+7. Copy the service file to systemd's system directory. `sudo cp /var/lib/xmpp-discord-bridge/xmpp-discord-bridge/optional/xmpp-discord-bridge.service /etc/systemd/system/`
2929+8. Read through the [XMPP](#XMPP) and [Discord](#Discord) sections and make sure the listed requirements are met.
3030+9. Start and enable the bridge. `sudo systemctl enable --now xmpp-discord-bridge.service`
3131+3232+### XMPP
27332828-# If a message is reacted to, send the following to the MUC:
2929-# > [Message content]
3030-# + :someemoji:
3131-reactions_compat = true
3434+In order for the bridge to work, it needs to have an affiliation of `owner` before joining. Going off of the example.toml, it would have the JID of `bot@discord.example.com`.
3535+The virtual users that follow will be automatically added to the room with an affiliation
3636+of `member`.
32373333-# Use the XMPP user's avatar in the webhook. For options, see
3434-# the [avatars] section
3535-relay_xmpp_avatars = false
3838+### Discord
36393737-# When a user is mentioned, also add the display name infront of the message body, e.g.
3838-# SomeUser, PapaTutuWawa: Hello @SomeUser and @PapaTutuWawa
3939-muc_mention_compat = true
4040+(based upon https://github.com/42wim/matterbridge/wiki/Discord-bot-setup)
40414141-# If true, then xmpp-discord-bridge will also make offline Discord users appear in the MUC.
4242-# If they are offline, then they will have a presence of "xa". If false, then offline users
4343-# will leave the MUC.
4444-dont_ignore_offline = true
4242+#### Create Bot
45434646-# If true, when receiving a file to embed in Discord, the bridge will remove the URL from
4747-# the content, leaving only the embed behind. This prevents Discord users who disabled
4848-# link previews from viewing the embed.
4949-remove_url_on_embed = true
4444+You need to setup a "Bot" on Discord. Go [here](https://discord.com/developers/applications) and click "New Application".
50455151-# When sending files from Discord to XMPP, proxy the URLS with this template. "<hmac>" and
5252-# and "<url>" will be substituted. Proxy will not be used if not set.
5353-proxy_discord_urls_to = "https://proxy.server.example/proxy/<hmac>/<url>"
4646+Then give your bot a name. Click "Create". On the next screen, you can optionally set an Avatar Icon for your app and description.
54475555-# Secret for the proxy. Only used when the proxy is used.
5656-hmac_secret = "some-secret"
4848+Next, click on "Bot" on the left-hand menu. Then click "Add Bot", then "Yes Do It".
57495858-# Set to false to prevent the Discord channel description from being mirrored to the MUC ubject.
5959-mirror_subject = true
5050+On the "Bot" screen, click "Reset Token" and "Yes. Do It!". Then click "Copy" to copy it. Then paste it to "discord_token" in your `config.toml`.
60516161-# Set to false to prevent the Discord guild avatar from being copied to the MUC avatar.
6262-mirror_icon = true
5252+Optional: Here, you can also toggle if the bot is public, which will allow others to invite it to their servers.
63536464-[avatars]
6565-# Path where avatars can be stored
6666-path = "/some/path"
5454+Make sure to also toggle the "Server Members Intent" and "Message Content Intent" options further down under "Privileged Gateway Intents" to allow the bot to see the member list.
67556868-# URL on which the avatars will be available
6969-url = "https://im.server.example/avatars/"
5656+#### Invite Bot
70577171-[discord]
7272-[[discord.channels]]
7373-# The ID of the guild
7474-guild = 00000000000
5858+Now it's time to invite your bot to your server. Don't worry about your bot being started for this next step. On the left-hand menu click "OAuth2" and copy the Client ID into this URL then navigate to it.
75597676-# The ID of the channel to mirror
7777-channel = 000000000
6060+ https://discordapp.com/oauth2/authorize?&client_id=YOUR_CLIENT_ID_HERE&scope=bot&permissions=536870912
78617979-# The MUC to mirror into
8080-muc = "channel@muc.server.example"
8181-```
6262+The "permissions=536870912" at the end of the URL corresponds to the "Manage Webhooks" permission. It is required for the bridge to work correctly.
82638383-In order for the bridge to work, it needs to have an affiliation of `owner` before joining.
8484-The virtual users that follow will be automatically added to the room with an affiliation
8585-of `member`.
6464+Discord will ask you which guild to invite it to. Select the guild then Authorize it.
86658766## License
8867
+61
example.toml
···11+[general]
22+jid = "discord.example.com" # JID of the server component
33+secret = "" # Component secret
44+server = "example.com" # Address of the actual XMPP server
55+port = "5347" # Component port
66+discord_token = "" # Token of your Discord bot
77+88+# If a message is reacted to, send the following to the MUC:
99+# > [Message content]
1010+# + :someemoji:
1111+reactions_compat = true
1212+1313+# Use the XMPP user's avatar in the webhook. For options, see
1414+# the [avatars] section
1515+relay_xmpp_avatars = false
1616+1717+# When a user is mentioned, also add the display name infront of the message body, e.g.
1818+# SomeUser, PapaTutuWawa: Hello @SomeUser and @PapaTutuWawa
1919+muc_mention_compat = true
2020+2121+# If true, then xmpp-discord-bridge will also make offline Discord users appear in the MUC.
2222+# If they are offline, then they will have a presence of "xa". If false, then offline users
2323+# will leave the MUC.
2424+dont_ignore_offline = false
2525+2626+# If true, when receiving a file to embed in Discord, the bridge will remove the URL from
2727+# the content, leaving only the embed behind. This prevents Discord users who disabled
2828+# link previews from viewing the embed.
2929+remove_url_on_embed = true
3030+3131+# When sending files from Discord to XMPP, proxy the URLS with this template. "<hmac>" and
3232+# and "<url>" will be substituted. Proxy will not be used if not set.
3333+proxy_discord_urls_to = "https://proxy.example.com/<hmac>/<url>"
3434+3535+# Secret for the proxy. Only used when the proxy is used.
3636+hmac_secret = ""
3737+3838+# Set to false to prevent the Discord channel description from being mirrored to the MUC ubject.
3939+mirror_subject = true
4040+4141+# Set to false to prevent the Discord guild avatar from being copied to the MUC avatar.
4242+mirror_icon = true
4343+4444+[avatars]
4545+# Path where avatars can be stored. Make sure it is writable by the user the bridge is running under
4646+# and readable by your http service.
4747+path = "/var/www/html/avatars"
4848+4949+# URL on which the avatars will be available
5050+url = "https://example.com/avatars/"
5151+5252+[discord]
5353+[[discord.channels]]
5454+# The ID of the guild
5555+guild = 000000000
5656+5757+# The ID of the channel to mirror
5858+channel = 000000000
5959+6060+# The MUC to mirror into
6161+muc = "channel@muc.server.example"