Lint / JS (eslint) (pull_request) Successful in 10s
Lint / Shell (shellcheck) (pull_request) Successful in 11s
Lint / No Hookshot webhook IDs in README (pull_request) Successful in 6s
Lint / No secrets in webhook configs (pull_request) Successful in 6s
Lint / Landing page is rendered (matrix (pull_request) Successful in 6s
Lint / Python (ruff) (pull_request) Successful in 7s
Lint / Secret scan (gitleaks) (pull_request) Successful in 13s
Lint / Shell (shellcheck) (push) Successful in 26s
Lint / JS (eslint) (push) Successful in 18s
Lint / No Hookshot webhook IDs in README (push) Successful in 21s
Lint / No secrets in webhook configs (push) Successful in 12s
Lint / Python deps (pip-audit) (pull_request) Successful in 1m54s
Lint / Landing page is rendered (matrix (push) Successful in 17s
Lint / Python (ruff) (push) Successful in 16s
Lint / Secret scan (gitleaks) (push) Successful in 31s
Lint / Python deps (pip-audit) (push) Successful in 1m37s
mautrix-discord doesn't bridge presence. lotus_presence.py watches the Discord server (a second gateway session on the bridge's own bot, Guilds + Presence intents only) and sets presence and a status message on each @discord_* ghost: online / idle / DND / offline -> online / unavailable / msc3026 busy / offline; custom status and the first activity become the status message. Its own appservice registration is non-exclusive on the ghost namespace, so it can update ghosts but not create them. Synapse drops an unrefreshed user to offline after about a minute, so live states are re-sent every 20 s; if the service dies, ghosts go offline rather than stale. The installer generates the credentials on the server and doesn't restart Synapse. Statuses and activities are never logged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
57 lines
2.1 KiB
Bash
57 lines
2.1 KiB
Bash
#!/bin/bash
|
|
# One-time install of the Discord presence service (lotus_presence.py).
|
|
# Run on LXC 151 with this repo's main branch pulled to /opt/matrix-config:
|
|
# bash /opt/matrix-config/discord-bridge/install-presence.sh
|
|
# Generates its own appservice credentials on this machine and never prints them.
|
|
# Does NOT restart Synapse: until you do, Discord works but Matrix answers 401.
|
|
# Safe to re-run: existing credentials are kept.
|
|
set -euo pipefail
|
|
|
|
REPO=/opt/matrix-config
|
|
REG=/etc/matrix-synapse/discord-presence-registration.yaml
|
|
ENV_FILE=/etc/lotus-presence/env
|
|
HS=/etc/matrix-synapse/homeserver.yaml
|
|
|
|
install -d -m750 -o root -g mautrix-discord /etc/lotus-presence
|
|
install -D -m644 "$REPO/discord-bridge/lotus_presence.py" /opt/lotus-presence/lotus_presence.py
|
|
|
|
if [ ! -f "$ENV_FILE" ]; then
|
|
AS_TOKEN="$(openssl rand -hex 32)"
|
|
HS_TOKEN="$(openssl rand -hex 32)"
|
|
(umask 027; printf 'AS_TOKEN=%s\n' "$AS_TOKEN" > "$ENV_FILE")
|
|
chown root:mautrix-discord "$ENV_FILE"
|
|
(umask 027; cat > "$REG" <<YAML
|
|
# Discord presence service. Non-exclusive on the ghost namespace: it updates
|
|
# presence on ghosts the text bridge owns, and cannot create them.
|
|
id: lotus-discord-presence
|
|
url: null
|
|
as_token: $AS_TOKEN
|
|
hs_token: $HS_TOKEN
|
|
sender_localpart: discordpresence
|
|
rate_limited: false
|
|
namespaces:
|
|
users:
|
|
- regex: '^@discord_[0-9]+:matrix\.lotusguild\.org$'
|
|
exclusive: false
|
|
rooms: []
|
|
aliases: []
|
|
YAML
|
|
)
|
|
chown root:matrix-synapse "$REG"
|
|
echo "generated appservice credentials"
|
|
else
|
|
echo "keeping existing credentials"
|
|
fi
|
|
|
|
if ! grep -qF "$REG" "$HS"; then
|
|
cp -p "$HS" "$HS.bak-presence-$(date +%Y%m%d%H%M%S)"
|
|
sed -i "/^app_service_config_files:/a\\ - $REG" "$HS"
|
|
echo "added the registration to homeserver.yaml (takes effect on the next Synapse restart)"
|
|
fi
|
|
|
|
install -m644 "$REPO/systemd/lotus-discord-presence.service" /etc/systemd/system/lotus-discord-presence.service
|
|
systemctl daemon-reload
|
|
systemctl enable --now lotus-discord-presence
|
|
systemctl restart lotus-discord-presence
|
|
echo "installed. Restart Synapse once to activate the registration: systemctl restart matrix-synapse"
|