Ziad ArafatandClaude Opus 5.5 85bcee8c1a Self-test cog, cog requirement conflict check, health records
- dogebot.depcheck: find lib packages whose requirements Red's venv
  shadows (Red appends Downloader's lib to sys.path). Catches the
  2026-11-09 anyio/typing_extensions break; verified on the old lib.
- dogesetup.after_update: run it after provisioning and every cog
  update, write the deps health record, dispatch dogebot_cogs_ready.
- dogebot.health: /data/health/<check>.json for the Kuma push script.
- cogs/selftest: after every cog update and on [p]selftest run, runs
  watch search + watch status + alignment as the owner in the test
  channel, renders a sample chart, and plays music at volume 0 in an
  empty voice channel; reports to the channel and health.
- start.install_bundled_cogs ships every cog in cogs/; manifest loads
  selftest last.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 09:05:05 -07:00

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 daily, together with its YouTube plugin and yt-cipher, so that playback keeps working when YouTube changes.

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
  timer -.->|podman auto-update| 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 ghcr.io/kikkia/yt-cipher:master daily, podman auto-update with rollback
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.

Cogs

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 TV and WEB clients.
  • yt-cipher, which deciphers YouTube's stream signatures for the plugin.

dogebot-update (daily, from dogebot-update.timer):

  1. 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).
  2. For each new combination, release first, builds an image tagged :candidate.
  3. Starts that candidate next to the live Lavalink and checks that it can search YouTube and load a YouTube video (src/dogebot/lavalink.py).
  4. 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.
  5. 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.
  6. Runs podman auto-update for yt-cipher and Postgres.

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.

S
Description
Dogebot: Red-DiscordBot with self-updating music (Lavalink + youtube-source + yt-cipher), deployed with podman quadlets
Readme
276 KiB
0 Stars 1 Watchers 0 Forks
Languages
Python 74.5%
Go 17.4%
Dockerfile 4.1%
Shell 2.5%
TypeScript 1.5%