The panel now carries a picture with the cover, title, progress and a waveform measured from the audio, redrawn every 20 s while people listen. Discord's buttons stay under it. Without Attach Files it falls back to the text card. Edits replace the old picture, for role menus too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
109 lines
20 KiB
Markdown
109 lines
20 KiB
Markdown
# Dezio (Rust) — roadmap
|
||
|
||
Port of the Python bot in `~/Projects/Discord Bot` (kept until this reaches parity). Backups: `~/Projects/Discord Bot-backups/dezio-python-2026-10-23.tar.gz`, Chromebook `/root/dezio-python-2026-10-23-pre-rust.tar.gz`.
|
||
|
||
Stack: tokio, twilight (gateway/http/model — has Components V2 `Container` etc.), songbird for voice, serde. Build on the PC (`~/.cargo/env`), copy the release binary to the Chromebook (x86_64).
|
||
Never log in with the real token on the PC (the live bot would answer twice).
|
||
|
||
Order: 1 core (config, JsonStore with debounce, V2 card builder, command framework, prefix `D!` + slash) → 2 admin/moderation/logs → 3 utility/search/info/help → 4 media (/download incl. parallel convert) → 5 fun/AI/games/casino → 6 music + Last.fm → 7 dashboard + Game Boy Activity server + TUI → 8 data migration check against the old `data/*.json`.
|
||
|
||
FINAL STEP (owner request): fix the Chromebook's start-at-boot service (systemd unit for the Rust binary; previously the bot ran by hand in screen).
|
||
|
||
## Status
|
||
- Stage 1 (2026-10-23): paths, JsonStore (same file format, debounced atomic saves), V2 `Card` builder, one command framework for `D!` + slash (per-guild prefix from data/prefixes.json, permission check, user-install contexts, slash sync with hash), commands `ping` and `prefix`. 5 unit tests pass; release binary builds (14 MB). NOT run against Discord: the bot only connects when `DEZIO_LIVE=1` (set that on the Chromebook only).
|
||
- Stage 2a (2026-10-23): member/role cache (twilight-cache-inmemory, members requested on GuildCreate), converters (durations, member lookup by name/mention/id/reply), error cards (user errors / 403 / unexpected), permission + role-hierarchy checks, Moderation (kick, ban, unban, timeout, untimeout, nick, role, slowmode), purge (all 15 filters, bulk + one-by-one, Stop button, progress card), help (categories, paged, detail pages, select menu, works after restarts). 18 unit tests incl. a check that every help page fits Discord's V2 limits.
|
||
- Not yet in 2a: /unban and /timeout autocomplete, `help` autocomplete, bot-permission pre-checks, per-command cooldowns.
|
||
- Next: stage 2b = logs (audit-log matching, 1174 lines in Python), welcome, role menus, channel tools, dashboard cog.
|
||
|
||
## Stage 2b status (2026-10-23)
|
||
- Done: cdn link refresher, welcome/goodbye/autorole/sticky roles (setup panel with channel + role selects, edit modal, test; join/leave/pending handlers), reqwest HTTPS (tested), 21 unit tests.
|
||
- Still to do in 2b: logs (audit-log matching), channel tools (lock/media/reddit/nsfw/pin), role menus.
|
||
|
||
## Role menus — owner request (keep presets, but configurable in Discord AND on the website)
|
||
Today: stock categories live in assets/data/role_menus.json (name, emoji, role names); each server only picks which preset
|
||
names to use (data/role_menus.json: {guild: {cat: {roles:[names], stock:"one"|"many"}, public_messages:{cat:{channel,message}}}}),
|
||
and only through the Discord editor; the dashboard has no role-menu page.
|
||
Plan (backward compatible with the existing file):
|
||
- Presets stay as templates. A server's category may override `name` and `emoji`, edit its `roles` (add/remove/reorder, any
|
||
name, not just preset ones; missing roles are created with a colour on publish), switch `stock` one/many, and can be a
|
||
brand-new `custom` category. "Reset to preset" restores the template.
|
||
- Discord: `/cosmetics` editor gets rename/emoji/add role/remove role/reset, plus "New custom menu".
|
||
- Website: a Role menus page with the same operations, saving to the same file; the bot re-publishes in place.
|
||
- Role menus, Discord side DONE (2026-10-23): `/cosmetics` (`D!cosmetics`) overview + editor — rename/emoji, add own roles, tick roles, pick one/many, reset to preset, new/delete custom menus, Publish (creates/deletes roles, posts or edits the dropdown in place); member dropdowns work from the message itself. Reads the existing data/role_menus.json (checked against a copy of the real file). The website page comes with the Rust dashboard (stage 7); the file format above is the shared contract.
|
||
- Still open in 2b: logs, channel tools (lock/media/reddit/nsfw/pin).
|
||
|
||
## Stage 2b — DONE (2026-10-23)
|
||
- Channel tools: `/lock` `D!lock` `D!unlock` (saved overwrites in the Python bot's own format), `/media`, `/reddit` `D!unreddit`, `/setnsfw` `D!nsfw`, right-click "Pin Message" with a persistent Unpin button (framework now supports message context menus).
|
||
- Logger: audit-log matching (pushed entries, claims, merged message-delete/voice credits), batched webhook delivery (falls back to the bot), `/logging` setup panel, and handlers for bans, joins (with the invite used), leaves/kicks, AutoMod, pins, prune, message delete/edit/bulk (with transcript), member nick/roles/timeout/boost/screening, voice, channels + permission changes, threads, stages, webhooks, roles, emoji, stickers, server settings, scheduled events. Reads the existing data/logging.json.
|
||
- Differences from Python worth knowing: other people's username/avatar changes are noticed through member updates (Discord only sends the bot's own user updates); message edit/delete logs need the message to be in the 3000-message cache, as before.
|
||
- 35 unit tests. Nothing tested against Discord yet.
|
||
- Next: stage 3 = utility/search/info (userinfo, serverinfo, avatar, weather, wiki, define, calculator, snipe, afk, embed builder…).
|
||
|
||
## Stage 3a — DONE (2026-10-23)
|
||
- Info cards: userinfo, serverinfo, channelinfo, roleinfo, avatar, banner + "Show Avatar"/"Show Banner" right-click apps (framework now has user menus), card colours taken from avatars/icons (`colors.rs`: median-cut palette like the Python version, cached), per-user/server prefs (`prefs.rs`, data/users.json + servers.json), snipe (deleted/edited/reactions, opt-out, paging), afk (+ welcome-back list), mpreg. 47 unit tests.
|
||
- Still open in stage 3 (3b): tools.py (calculate with keypad, color, translate, weather, viruscheck), search.py (web/image search, wikipedia, define, urban, rule34), embeds.py (/embed builder + "Edit Embed"), and the rest of other.py (dm_echo, /ad, smash, serverclone, owner DMs on join/leave).
|
||
|
||
## Stage 3b (tools) — DONE (2026-10-23)
|
||
- Calculator (own expression parser: big integers, `2^10`, `sin 30`, `5!`, `√16`, old `16 sqrt` style, same error messages; the button keypad keeps its state on the card itself so it survives restarts), colour tool (swatch PNG drawn with the bundled Noto fonts, formats, matches, Lighter/Darker/Complement/Random buttons), translate (`D!tr`, "Translate Message" app, Google + MyMemory fallback), weather (Open-Meteo + ZIP + OpenStreetMap geocoding, autocomplete, °C/°F memory, private "saved place"), VirusTotal (link/file, free-tier limits).
|
||
- Framework: autocomplete, file-attachment options, replies with a file, private "thinking" answers.
|
||
- Verified against the live services: Paris / Denver Colorado / Springfield, IL / 10001 / Tokyo geocode and forecast correctly (`cargo test live_weather -- --ignored`). 65 unit tests.
|
||
- Still open in stage 3 (3c): search.py (web/image search, wikipedia, define, urban, rule34), embeds.py (/embed builder + "Edit Embed"), rest of other.py (dm_echo, /ad, smash, serverclone, owner DMs on join/leave).
|
||
|
||
## Stage 3c — DONE (2026-10-23) — stage 3 complete
|
||
- Search: `/search` + `D!image` (DuckDuckGo html/lite/instant, Bing → Openverse → Zenserp images), Wikipedia (sections, languages, "other matches", random, `fr: Paris`), define (+ pronunciation audio, Urban Dictionary fallback), `D!urban`, rule34 (age-restricted only, same blocklist, TBIB/Xbooru). Generic pager (`pager.rs`) for result pages.
|
||
- Embed builder (`/embed`, "Edit Embed"): the preview embed is the draft, so editors survive restarts; text/images/author/footer/fields/JSON/import.
|
||
- `dm_echo`, `/ad` (+ the persistent edit button/form), `smash`/`smashstats`, owner-only `serverclone` (with a confirm prompt: `confirm.rs`), and DMs to server owners when the bot is added/removed.
|
||
- Framework: cooldowns, owner-only commands.
|
||
- Verified against the live services: web search, image search, Wikipedia (8 sections, 59 languages), dictionary, Urban Dictionary (`cargo test live_search -- --ignored`). 81 unit tests; 53 commands/menus registered.
|
||
- Next: stage 4 = media (/download incl. the parallel convert, images/effects, quote, emoji).
|
||
|
||
## Stage 4 — DONE (2026-10-23) — media
|
||
- **Text engine** (`text.rs`, cosmic-text): real shaping + per-character font fallback, so Latin, CJK, Arabic (right-to-left), Indic, Thai, symbols and COLOUR emoji all draw. Fonts ship in `assets/fonts/` (Noto Sans + `fallback/`: CJK, Arabic, Hebrew, Indic scripts, Symbols, Math, Noto Color Emoji ≈ 75 MB with the rest of assets). Google Fonts picked by name are downloaded once (no API key now: the public CSS endpoint) into `data/fonts/google/`.
|
||
- **Quotes** (`media/quote.rs`): right-click → Create Quote, or reply `D!quote`. Default = the familiar "quote bot" look (greyscale portrait fading into black on the left, centred quote, "- Name", "@handle", small watermark — 1200×630). Presets: Classic, **Portrait** (630×790: picture fading into black, big quote marks, text, divider line, small avatar icon + @handle), and the four older circle styles. On the card: preset, font (any Google Font), layout, flip, B&W/colour, quote marks, name, @handle, divider, icon (off/avatar/server), bold, and a form for size / text colour / background / gradient / watermark. **Save as my default** / **Save for this server** (Manage Server) / Reset. The watermark defaults to "Dezio" (editable, empty = none).
|
||
- Shared file for the dashboard: `data/quote.json` = `{"users": {"<id>": Style}, "servers": {"<id>": Style}}`; every `Style` key has a default, so partial objects are fine. Keys: preset, layout (wide|portrait), image (fade|circle|none), grayscale, flip, bg, bg2 (gradient end or null), text, author, muted, font, bold, size (0 = fit), marks, name, handle, line, icon (none|avatar|server), watermark, quote_chars. Resolution order: your style → server style → Classic.
|
||
- **Image effects** (`media/images.rs`): `/image` (`D!fx`): all 10 effects and 14 filters, GIFs/animated WebP keep their animation, size-aware re-render for the upload limit. NEW `convert` option (also `/convert` and `D!convert <format>`): picture/GIF/video → gif, mp4, webm, png, jpg, webp or mp3 (ffmpeg; retries smaller settings until it fits; a still picture becomes a 3 s clip). Sources: attachment, replied message (attachments, embed video/image, stickers), link, custom emoji, @user avatar. `/petpet` + `D!petpet`.
|
||
- **Emoji** (`media/emoji.rs`): `/steal`, `/combine` (Emoji Kitchen), `D!emoji` browser and the Get Assets menu with "Add to this server".
|
||
- **/download** (`media/download/`): the whole Python pipeline ported (yt-dlp + ffmpeg + gallery-dl as child processes): sizes checked before downloading (CDN asked when yt-dlp doesn't know), H.264+AAC preferred, size watchdog that drops to a smaller stream, **VP9/AV1/HEVC converted while downloading** (one ffmpeg reads yt-dlp's stream URLs directly; falls back to download-then-convert), ffprobe validation, one-pass compression, slideshows/carousels via gallery-dl, audio mode (Opus 96 kbps), progress card with Cancel, Delete + Original post buttons, upload retries, one job at a time. Verified against a local server (H.264, VP9, convert-while-downloading, audio, forced squeeze, cancel) and real links (a direct mp4 and a YouTube video).
|
||
- Framework: `Command::slash_as` (a slash name different from the text command: `/image` = `D!fx`), `find_slash`.
|
||
- Not tested against Discord. Known gaps: no per-command "I need Attach Files" pre-check; the quote card's controls stop working after a restart (sessions live in memory, as the Python view did).
|
||
- Next: stage 5 = fun / AI / games / casino.
|
||
|
||
## Stage 6 — DONE (2026-10-23) — music + Last.fm
|
||
- **Music** (`commands/music/`): songbird (with Discord's required voice encryption) for voice; yt-dlp lookups in separate processes; ffmpeg → PCM read ahead in a 15 s buffer (a stall plays silence instead of rushing; position counts real frames only). `/play` (search or link, playlists, YouTube mixes load 25 first then the rest), `/pause` `/resume` `/skip` `/stop` `/queue` `/nowplaying` `/seek` `/loop` `/shuffle` `/unqueue` `/volume` `/join` `/leave` + `D!mhelp`, aliases as before. Now-playing panel with buttons that carry `music:<action>:<guild>` (work after restarts), card colour from the cover, bitrate = channel bitrate (≤96 kbps), idle leave after 5 min, prefetch of the next stream, volume saved per server.
|
||
- **Last.fm** (`commands/lastfm/`): `/fm` (now playing, top, recent, profile, link), `D!ta/tab/tt/recent/fmprofile/fmset`, Who Knows (`D!wk/wkt/wka`, prefix only), `D!chart` collage (prefix only) (drawn with the new text engine), Pixel Jumble (`D!px`, prefix only: a linked member starts a round from their own albums, then anyone can answer by typing in chat or with the button), `/lyrics` (LRCLIB + lyrics.ovh), "Listen to song" button (yt-dlp → Opus file, private, deletes itself). Cards use the games engine (owner-only buttons, switch views, idle end). Reads data/lastfm.json.
|
||
- Verified live: Last.fm API (profile, top artists, not-found, album info); YouTube search → stream → ffmpeg → 204 real audio frames. NOT verified: actually joining a voice channel (needs Discord).
|
||
- Known gap: on a stage channel the bot asks to speak but can't auto-unsuppress (twilight's builder has no "suppress: false").
|
||
- Next: stage 7 = dashboard (+ role-menu page, quote styles page), Game Boy Activity server, TUI.
|
||
|
||
## Stage 7 — DONE (2026-10-23) — dashboard, Game Boy Activity, console
|
||
- **Dashboard** (`src/web/`, axum): the website, `/dashboard` (the same pages as before, extended), Discord sign-in (OAuth, sessions in data/dashboard_sessions.json — same format as Python, so people stay signed in), CSRF + same-origin checks, live Manage Server checks from the member cache. API: `/api/me`, `/api/user` (Last.fm link, AFK, download quality, weather, privacy, **quote style**), `/api/guilds/<id>` (prefix, music volume, snipe, logging channels, welcome/goodbye + autoroles, AI personality/lock, **server quote style**, **role menus**), `/api/places`, `/api/quote/preview` (the bot draws the preview, so it's exactly what Create Quote makes). `DASHBOARD_URL`, `DASHBOARD_CLIENT_SECRET`, `DASHBOARD_HOST/PORT` as before.
|
||
- New pages: **Quote style** (preset, layout, picture mode, toggles, icon, any Google Font, size, colours, gradient, watermark, live preview; saved as the person's default or the server's default → data/quote.json) and **Role menus** (edit presets, add roles, one/many, reset to preset, new custom menus, publish to a channel — the same data and publish code as `/cosmetics`).
|
||
- **Game Boy Activity** (`src/web/activity.rs`, `commands/gameboy.rs`): the same API as the Python server (config, token, web-session, library with covers from SteamGridDB, ROM download, battery saves, save states, legacy saves); `/gameboy` launches the Activity (raw interaction callback type 12), `D!gameboy` posts a Play card; slash sync keeps Discord's "Launch" entry-point command.
|
||
- **Console** (`src/tui.rs`, ratatui): live stats header, Activity / Console / Commands / Servers tabs, command box (`help`, `sync`, `status <text|reset>`, `send <channel> <text>`, `servers`, `leave <id>`, `clear`, `quit`). Starts when the bot runs in a terminal; `--headless` or no terminal (systemd) logs as plain text. Not ported: cog reload/load/unload (nothing to reload in a binary) and the Python self-test tab (the Rust tests replace it).
|
||
- **Status**: "Watching In N servers | /help | D!help" (+ owner `setstatus` / `resetstat`).
|
||
- `--web-dev` serves only the web pages with a made-up signed-in session (cookie `dezio_session=devtoken`, http://127.0.0.1:8099) for looking at the dashboard without Discord. Checked in the browser: the quote editor draws wide and portrait previews (Latin/Japanese/Arabic/emoji) and saves.
|
||
- 7 web tests (pages + security headers, sign-in gate, CSRF/origin refusals, settings saved and validated, quote preview PNG, ROM library + saves per player).
|
||
- Not tested: the server-settings endpoints (they need a live server cache), OAuth against Discord, the Activity inside Discord.
|
||
- Note: ~/Projects/Dezio/data/ holds leftovers from the unit tests (fake ids); it's git-ignored and gets replaced by the real Python data in stage 8.
|
||
- Next: stage 8 = run against the real data/*.json from the Python bot, a final comparison of every command, then deploy + the Chromebook boot service.
|
||
|
||
## Stage 8 — IN PROGRESS (2026-10-23) — parity check
|
||
- Data: compared every file in the Python `data/` with what the Rust code reads (afk, ads, ai, casino, channels, confessions, cookieclicker, lastfm, logging, prefixes, reaction_roles, role_menus, snipes, status_roles, sticky_roles, temp_roles, welcome): same names and shapes, so the Python files can be copied over as they are. `users.json` / `servers.json` don't exist in Python's data yet (created on first use).
|
||
- Command comparison (every Python command, alias and slash name vs the Rust registry) found one gap: **reaction roles, temporary roles and status roles** (`roles.py`). Now ported in `src/commands/reactionroles.rs`: `D!rr add|remove|list|<mode> [minutes]`, `/reactionrole`, `/rr-type`, `/rep` (+ `D!rep`), the reaction add/remove handler (normal, toggle, unique, verify, temporary), a 30 s expiry loop, and status-role sync on presence changes, joins and `/rep` changes. Uses the real data (4 reaction-role messages, one `/hurtme` status role).
|
||
- Not ported on purpose: the owner-only `D!dashboard` (the web server starts by itself), `D!selftest` (Rust tests replace it).
|
||
- Still to do: deploy to the Chromebook and fix its start-at-boot service (needs the owner's go-ahead because it replaces the running Python bot); Python files stay until the owner says to delete them.
|
||
|
||
## Stage 8 — DONE (2026-10-23) — deployed
|
||
- Chromebook (192.168.1.71): Rust bot in `/root/Dezio` (binary, assets, web, copy of Python's data + .env). `dezio-bot.service` now runs `/root/Dezio/dezio --headless` (DEZIO_LIVE=1), enabled at boot, Restart=always; the health-check timer still checks :8080. Python bot stopped (its files in `/root/Discord Bot` untouched).
|
||
- Backups: `/root/dezio-bot.service.bak` (old unit), `/root/dezio-python-data-*-pre-switch.tar.gz`, `/root/dezio-python-2026-10-23-pre-rust.tar.gz`.
|
||
- Rollback: `systemctl stop dezio-bot; cp /root/dezio-bot.service.bak /etc/systemd/system/dezio-bot.service; systemctl daemon-reload; systemctl start dezio-bot`.
|
||
- Fix found on first start: slash descriptions over 100 characters made Discord refuse the whole sync; they're now cut to 100.
|
||
- Source: forgejo:astar76/Dezio.git (branch master).
|
||
|
||
## Dashboard and website redesign (2026-11-06)
|
||
- Direction: a mixing desk at night. Graphite surfaces, orchid accent, the logo's diamond facet as the mark on controls. Tokens in `web/site/assets/tokens.css`, fonts self-hosted in `web/site/assets/fonts/` (the CSP blocks font CDNs), vector logo in `web/site/images/mark.svg`.
|
||
- Dashboard controls live in `web/dashboard/static/controls.js` (faders, switches, segments, searchable pickers, colour picker). Every control fires a bubbling `input`; sections go through one save bar.
|
||
- The server page has only been looked at with faked API answers (`--web-dev` has no Discord cache). Not checked on the live bot yet.
|
||
- Fixed: role menus published from the dashboard no longer claim roles they didn't make (taking one out used to delete a server's own role); zero ids no longer panic `D!ban`; announcement channels show in the pickers; static files revalidate after an update.
|
||
- Music panel: a picture drawn by `commands/music/card.rs` (cover, title, the song's real waveform from `source::peaks`, progress), redrawn every 20 s while people listen, with Discord's buttons under it. Without Attach Files the panel falls back to the text card. Rendering and analysis are tested; the panel itself has not been run against Discord.
|
||
- Known gap, unchanged: on a stage channel the bot can't unsuppress itself (twilight's `suppress()` only sets true).
|