Merge pull request 'discord-bridge: bot profile, down alert, login-owner account' (#48) from discord-bridge-profile into main
Lint / JS (eslint) (push) Successful in 8s
Lint / Shell (shellcheck) (push) Successful in 8s
Lint / No secrets in webhook configs (push) Successful in 8s
Lint / Landing page is rendered (matrix (push) Successful in 8s
Lint / Python (ruff) (push) Successful in 15s
Lint / Secret scan (gitleaks) (push) Successful in 7s
Lint / Python deps (pip-audit) (push) Successful in 55s
Lint / JS (eslint) (push) Successful in 8s
Lint / Shell (shellcheck) (push) Successful in 8s
Lint / No secrets in webhook configs (push) Successful in 8s
Lint / Landing page is rendered (matrix (push) Successful in 8s
Lint / Python (ruff) (push) Successful in 15s
Lint / Secret scan (gitleaks) (push) Successful in 7s
Lint / Python deps (pip-audit) (push) Successful in 55s
This commit was merged in pull request #48.
This commit is contained in:
@@ -424,6 +424,15 @@ Skip `guilds bridge`: it sets the guild to create a Matrix room for every channe
|
||||
old room). The relay webhook stays with the channel. Keep `@discordbot` at the default power level so it
|
||||
can't overwrite the room's name and icon with the Discord channel's.
|
||||
|
||||
**Bot profile:** `@discordbot` shows as "Discord Bridge" with the Discord logo
|
||||
(`discord-bridge/bot-avatar.png`). To reapply it: `pct exec 151 -- bash /opt/matrix-config/discord-bridge/set-bot-profile.sh`.
|
||||
|
||||
**Who the Discord bot login belongs to:** whichever Matrix account ran `login-token bot` sends its own
|
||||
messages to Discord *as the bot* ("matrix-bridge APP"), not through the relay webhook. So it lives on a
|
||||
dedicated account, `@discord-relay:matrix.lotusguild.org`, which never chats. Everyone else, admins
|
||||
included, stays logged out of the bridge and is relayed under their own name and avatar. Logging the
|
||||
bot in on one account automatically logs out any other account that had it.
|
||||
|
||||
**Rotating the bot token:** reset it in the Developer Portal, then DM the bridge bot `logout` and
|
||||
`login-token bot <new token>`.
|
||||
|
||||
@@ -1006,6 +1015,7 @@ Checklist in this file.
|
||||
| PostgreSQL Down | `pg_up` < 1 for 2m | critical |
|
||||
| LiveKit Down | `up{job="livekit"}` < 1 for 2m | critical |
|
||||
| Hookshot Down | `up{job="hookshot"}` < 1 for 2m | critical |
|
||||
| Discord Bridge Down | `node_systemd_unit_state{name="mautrix-discord.service",state="active"}` < 1 (or no data) for 3m | critical |
|
||||
| Draupnir Down | `up{job="draupnir-node"}` < 0.5 for 2m | critical |
|
||||
| PG Connection Saturation | connections > 80% of max for 5m | warning |
|
||||
| Federation Queue Backing Up | pending PDUs > 100 for 10m | warning |
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
@@ -61,7 +61,7 @@ appservice:
|
||||
username: discordbot
|
||||
# Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty
|
||||
# to leave display name/avatar as-is.
|
||||
displayname: Discord bridge bot
|
||||
displayname: Discord Bridge
|
||||
avatar: mxc://maunium.net/nIdEykemnwdisvHbpxflpDlC
|
||||
|
||||
# Whether or not to receive ephemeral events via appservice transactions.
|
||||
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
# Gives @discordbot the Discord logo and the display name "Discord Bridge".
|
||||
# Run inside LXC 151 (from the Proxmox node):
|
||||
# pct exec 151 -- bash /opt/matrix-config/discord-bridge/set-bot-profile.sh
|
||||
# Uploads bot-avatar.png as the bridge bot, points config.yaml at it and
|
||||
# restarts the bridge, which applies the profile on startup. Safe to re-run.
|
||||
set -euo pipefail
|
||||
|
||||
DIR=/opt/mautrix-discord
|
||||
CFG="$DIR/config.yaml"
|
||||
AVATAR=/opt/matrix-config/discord-bridge/bot-avatar.png
|
||||
BOT="@discordbot:matrix.lotusguild.org"
|
||||
|
||||
AS_TOKEN=$(awk '/^as_token:/ {gsub(/"/, "", $2); print $2; exit}' "$DIR/registration.yaml")
|
||||
[ -n "$AS_TOKEN" ] || { echo "no as_token in $DIR/registration.yaml" >&2; exit 1; }
|
||||
|
||||
MXC=$(curl -fsS -X POST \
|
||||
-H "Authorization: Bearer $AS_TOKEN" \
|
||||
-H "Content-Type: image/png" \
|
||||
--data-binary "@$AVATAR" \
|
||||
"http://127.0.0.1:8008/_matrix/media/v3/upload?filename=discord.png&user_id=${BOT/@/%40}" |
|
||||
python3 -c 'import json, sys; print(json.load(sys.stdin)["content_uri"])')
|
||||
echo "uploaded $MXC"
|
||||
|
||||
# Only the bot block's two lines; the 8-space indent is unique to appservice.bot.
|
||||
sed -i -E \
|
||||
-e 's|^( displayname: ).*$|\1Discord Bridge|' \
|
||||
-e "s|^( avatar: )mxc://.*$|\1$MXC|" \
|
||||
"$CFG"
|
||||
grep -A7 '^ bot:' "$CFG"
|
||||
|
||||
systemctl restart mautrix-discord
|
||||
sleep 3
|
||||
systemctl is-active mautrix-discord
|
||||
Reference in New Issue
Block a user