Dogebot
A Discord bot built on Red-DiscordBot 3.5, deployed as rootless podman containers with quadlets. Music (Audio, AudioTrivia) runs on its own Lavalink, which updates itself and its YouTube plugin daily. Signature deciphering uses a pinned Bun cipher base with isolated, tested EJS repairs managed by the music watchdog.
What runs
graph LR
discord[Discord] --- red[dogebot-red<br/>Red 3.5 + dogesetup cog]
red --> pg[(dogebot-postgres)]
red -->|ws :2333| lava[dogebot-lavalink<br/>Lavalink 3.7 red build<br/>+ youtube-plugin]
lava -->|signatures| cipher[dogebot-yt-cipher]
lava --> yt[YouTube / SoundCloud / ...]
timer[dogebot-update.timer] -.->|build, smoke test, swap| lava
operator -.->|reviewed source build| cipher
| Container | Image | Updates |
|---|---|---|
dogebot-red |
localhost/dogebot-red:latest, built from containers/red |
rebuild after changing uv.lock |
dogebot-lavalink |
localhost/dogebot-lavalink:current, built from containers/lavalink |
daily, by dogebot-update (below) |
dogebot-yt-cipher |
pinned Bun base plus accepted local repair tags, AlmaLinux10 + Bun | gated EJS repair agent; see music repair operations |
dogebot-postgres |
docker.io/library/postgres:16-alpine |
daily, podman auto-update with rollback |
All four share the dogebot network. Only Lavalink publishes a port, on 127.0.0.1:2333, for the smoke test.
Bun cipher deployment
The cipher is built from ToddyTheNoobDud/yt-cipher-bun commit
912033c880d4ef219261381486ee0ba586d6b7a9, including its pinned EJS submodule.
Its published GHCR image was not anonymously accessible during migration, so
containers/yt-cipher/Containerfile builds the source with pinned Bun and
AlmaLinux10 base-image digests. No compiler or Bun runtime is installed on the
hypervisor. Build on the Yveltal VM:
podman build -t localhost/dogebot-yt-cipher:bun-912033c -f containers/yt-cipher/Containerfile .
The internal name/port remain dogebot-yt-cipher:8001 and the existing Podman
secret dogebot-yt-cipher-token supplies API_TOKEN. Lavalink's remoteCipher
URL/password settings remain compatible. No host port is published. The runtime
is UID/GID1000 with keep-id, one worker, one CPU and512MiB maximum memory. Public
player scripts persist in the new named volume dogebot-yt-cipher-bun-cache.
The old Deno-specific OVERRIDE_PLAYER_VARIANT=IAS variable is not used by this
fork and was removed.
This local image is deliberately not registry auto-updated. To upgrade, review a new upstream commit, change the source ref/image tag, build it, test an isolated candidate, then update the Quadlet. Keep the old image/Quadlet for rollback. The daily Lavalink/YouTube plugin and Postgres update paths remain. Targeted EJS solver repairs are automated separately by the music watchdog below; pause that timer before manually replacing its accepted cipher image. The pinned source still resolves the upstream package ranges at build time; the deployed image digest identifies the exact built artifact.
Upstream authentication rejects a missing/incorrect token with a JSON error
body and HTTP200, so status200 alone is not a valid health/authentication check.
An authenticated /health response must contain status=ok and
service=yt-cipher-bun. Validate actual player STS/signature processing and
Lavalink playback when upgrading.
Cogs
Additional bot owners can be configured on the deployment host in
~/.config/dogebot/owners.env as RED_CO_OWNERS=123456789,987654321.
Restart dogebot-red.service after changes. These IDs are passed through Red's
--co-owner option and supplement the existing application owner. Co-owners have
full bot and host-data access; only list trusted administrators.
src/dogebot/manifest.py lists them. On every start the dogesetup cog adds the repos, installs missing
cogs, loads everything, updates the repos (reloading cogs that changed), and points Audio at dogebot-lavalink.
It updates again every 24 hours (DOGEBOT_COG_UPDATE_HOURS). Owners can run d!dogesetup to do all of that at once.
| Cog | From |
|---|---|
| admin, audio, mod, modlog, permissions, reports, warnings | Red (core) |
| starboard, roletools, serverstats | TrustyJAID/Trusty-cogs |
| audiotrivia | bobloy/Fox-V3 |
| reactchannel | PhasecoreX/PCXCogs |
| timezone | aikaterna/aikaterna-cogs (branch v3) |
| userinfo | flaree/Flare-Cogs |
| watch | RustyRaptor/doge_cogs: d!watch <title> preloads media into the webdav cache through the home lab's media-preload service |
| doge_alignment | RustyRaptor/doge_cogs: d!alignment / /alignment, a D&D alignment chart drawn with members' avatars (ImageMagick, its Pango coder and Noto Color Emoji are in the Red image for it) |
alignment guess asks yveltal's own Ollama (the ollama system service on port 11434, not part of this repo)
for a guess, using qwen3.5-9b-gpu with thinking off; see ALIGNMENT_MODEL_* in
deploy/quadlet/dogebot-red.container. If Ollama is down or the model is gone, the command says the model
failed and nothing else is affected.
SLASH_COMMANDS in the manifest lists slash commands to turn on. dogesetup enables any that aren't enabled
yet once their cog has loaded, and only then syncs with Discord, so the bot doesn't hit Discord's sync rate
limits on every start.
Music: how it stays working
YouTube playback depends on three moving parts:
- Lavalink itself. Red 3.5 speaks Lavalink's v3 protocol, so this is Red's own build of Lavalink 3.7, from Cog-Creators/Lavalink-Jars, not upstream Lavalink 4.
- The youtube-source plugin. It signs in to YouTube with
an OAuth refresh token and uses the
TVandWEBclients. - yt-cipher-bun, which deciphers YouTube's stream signatures using Bun.
dogebot-update (daily, from dogebot-update.timer):
- Finds the newest Red Lavalink build, the newest youtube-source release, and the newest youtube-source snapshot (a build of every commit, where YouTube fixes land first).
- For each new combination, release first, builds an image tagged
:candidate. - Starts that candidate next to the live Lavalink and checks that it can search YouTube and load a YouTube
video (
src/dogebot/lavalink.py). - Promotes the first candidate that passes: it becomes
:current(the old one is kept as:previous), and Lavalink restarts. If the restarted service fails the same check, it rolls back. - If the version already running still passes, it stops there. If it fails, for example because YouTube broke the release, it goes on to try the snapshot.
- Runs
podman auto-updatefor Postgres. The Bun cipher uses the pinned source build described below.
The versions running now are in ~/.local/state/dogebot/lavalink.json. To check music by hand:
LAVALINK_PASSWORD=$(podman secret inspect --showsecret --format '{{.SecretData}}' dogebot-lavalink-password) mise run smoke
The smoke test covers loading tracks, not actual playback, which needs a Discord voice connection.
Deploy
Needs rootless podman 4.4 or newer (quadlets), mise, and lingering for the user
(loginctl enable-linger).
git clone https://gitea.godemperordoge.org/ziadarafat/dogebot.git ~/src/dogebot
cd ~/src/dogebot && mise trust && mise install && mise run sync
DOGEBOT_DISCORD_TOKEN=... DOGEBOT_YOUTUBE_REFRESH_TOKEN=... DOGEBOT_PRELOAD_TOKEN=... \
deploy/install.sh # add --start to start the bot too
install.sh creates the podman secrets, builds both images, installs the quadlets into
~/.config/containers/systemd/dogebot/ and the timer into ~/.config/systemd/user/, and starts everything except
the bot. It leaves the bot stopped unless you pass --start, so that two copies never log in with one token.
| Podman secret | Used by | Source |
|---|---|---|
dogebot-discord-token |
Red (RED_TOKEN) |
DOGEBOT_DISCORD_TOKEN |
dogebot-youtube-refresh-token |
Lavalink | DOGEBOT_YOUTUBE_REFRESH_TOKEN |
dogebot-postgres-password |
Postgres, Red | generated |
dogebot-lavalink-password |
Lavalink, Red | generated |
dogebot-yt-cipher-token |
yt-cipher, Lavalink | generated |
dogebot-preload-token |
Red (PRELOAD_BOT_TOKEN, watch cog) |
DOGEBOT_PRELOAD_TOKEN |
If the YouTube refresh token stops working, Lavalink logs a device code: sign in at google.com/device with the bot's YouTube account, then put the new refresh token from the log into the secret.
systemctl --user status dogebot-red dogebot-lavalink dogebot-yt-cipher dogebot-postgres
journalctl --user -u dogebot-red -f
systemctl --user start dogebot-update # update Lavalink now
Development
mise installs uv, and uv installs Python 3.11 and the dependencies.
mise install && mise run sync
mise run fmt # ruff format + ruff check --fix
mise run check # lint, ty type check, tests
mise run build # both images
Ruff settings are the ones from the lptn projects (80 columns, 8-space indents, a wide rule set). Code is fully annotated and checked with ty.
dogesetup uses Red's internal Downloader and Core methods (the same ones behind [p]cog install). Red is
pinned in pyproject.toml, and tests/test_red_contract.py fails if an upgrade removes or renames them.
Automated music repair
See music repair operations for the isolated pi/Gemma/GPU-broker workflow,5-hour playback canaries, hourly upstream-patch retries,12-hour self-authoring fallback, and rollback controls.