diff options
| author | salmonik <raisersoft@proton.me> | 2026-07-08 02:13:35 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-07-08 02:13:35 +0200 |
| commit | cd8ed8bc5793985df2c1692072a932ceee517b95 (patch) | |
| tree | 42d18a4140259b5c68b4dd05b7fcb398f78b8d7f /README.md | |
| parent | Merge pull request 'Voice related fixes, alongside simplifying assistant' (#5... (diff) | |
| download | senator-sperma-cd8ed8bc5793985df2c1692072a932ceee517b95.tar.gz senator-sperma-cd8ed8bc5793985df2c1692072a932ceee517b95.zip | |
OPEN THE RUST GATES
Signed-off-by: salmonik <raisersoft@proton.me>
Diffstat (limited to '')
| -rw-r--r-- | README.md | 159 |
1 files changed, 95 insertions, 64 deletions
| @@ -1,92 +1,123 @@ | |||
| 1 | # Senator Sperma | 1 | # Senator Sperma (Rust) |
| 2 | 2 | ||
| 3 | A Discord bot with music playback, TTS, web search, and utility commands. | 3 | A Discord bot rebuilt in Rust from the original Python implementation. Music |
| 4 | playback via songbird, AI chat via OpenRouter or anything OpenAI compatible (ollama.cpp and such), TTS, web/file search | ||
| 5 | scheduled jobs, per-server triggers, QR codes, media conversion, and misc utilities. | ||
| 4 | 6 | ||
| 5 | Requires Python 3.14. | 7 | Built on poise 0.6 + serenity 0.12 + songbird 0.6, with async SQLite (sqlx 0.9) |
| 8 | for persistence. | ||
| 6 | 9 | ||
| 7 | ## Setup | 10 | ## Setup |
| 8 | 11 | ||
| 9 | ### 1. Clone & Create Virtual Environment | 12 | ### 1. Clone |
| 10 | 13 | ||
| 11 | ```bash | 14 | ```bash |
| 12 | git clone https://codeberg.org/salmonik/senator-sperma | 15 | git clone https://codeberg.org/salmonik/senator-sperma |
| 13 | cd senator-sperma | 16 | cd senator-sperma |
| 14 | python -m venv .venv | ||
| 15 | source .venv/bin/activate # Linux/macOS | ||
| 16 | # or .venv\Scripts\activate # Windows | ||
| 17 | ``` | 17 | ``` |
| 18 | 18 | ||
| 19 | ### 2. Install Dependencies | 19 | ### 2. System Dependencies |
| 20 | 20 | ||
| 21 | ```bash | 21 | The following binaries must be available on `PATH`: |
| 22 | pip install -r requirements.txt | 22 | |
| 23 | ``` | 23 | - `ffmpeg` — audio decoding/encoding for playback, conversion, and compression |
| 24 | - `qalc` (Qalculate) — used by `/math` to evaluate expressions | ||
| 25 | - `yt-dlp` (optional) — used by `/download` | ||
| 24 | 26 | ||
| 25 | You also need `ffmpeg` and `zbar` library and installed system-wide | 27 | Unlike the Python version, QR encode/decode is handled by the pure-Rust |
| 28 | `qrcode`/`rxing` crates — no `zbar` system library required. | ||
| 26 | 29 | ||
| 27 | ### 3. Create .env File | 30 | ### 3. Build |
| 28 | 31 | ||
| 29 | Create a `.env` file in the project root: | 32 | Requires a recent Rust toolchain (edition 2024). |
| 30 | 33 | ||
| 31 | ```bash | 34 | ```bash |
| 32 | cp .env.example .env | 35 | cargo build --release |
| 33 | ``` | 36 | ``` |
| 34 | 37 | ||
| 35 | Edit `.env` with your credentials: | 38 | ### 4. Configure Environment |
| 36 | 39 | ||
| 37 | ```env | 40 | Create a `.env` in the project root |
| 38 | # Required | 41 | look at `.env.example` on what to put there |
| 39 | TOKEN=your_discord_bot_token | ||
| 40 | 42 | ||
| 41 | # Optional - Bot Configuration | 43 | On launch, missing variables are reported via tracing (`error!` for required, |
| 42 | STATUS_CHANNEL_ID=123456789012345678 # Channel for startup message | 44 | `warn!` for optional with defaults). The database and schema migrations are |
| 43 | ASSISTANT_KEYWORD=jarvis # Keyword to trigger AI assistant | 45 | created automatically on first run. |
| 44 | 46 | ||
| 45 | # Optional - File Server (for music /search commands) | 47 | ### 5. Run |
| 46 | COPYPARTY_URL=http://localhost:8080 | ||
| 47 | COPYPARTY_PASSWORD=your_password | ||
| 48 | |||
| 49 | # Optional - AI commands | ||
| 50 | OPENROUTER_API_KEY= | ||
| 51 | ``` | ||
| 52 | |||
| 53 | ### 6. Run the Bot | ||
| 54 | 48 | ||
| 55 | ```bash | 49 | ```bash |
| 56 | python main.py | 50 | cargo run --release |
| 57 | ``` | 51 | ``` |
| 58 | 52 | ||
| 59 | ## Configuration | ||
| 60 | |||
| 61 | All settings are optional - defaults are provided if not set. | ||
| 62 | |||
| 63 | | Variable | Description | Default | | ||
| 64 | |---------|-------------|---------| | ||
| 65 | | `TOKEN` | Discord bot token | (required) | | ||
| 66 | | `STATUS_CHANNEL_ID` | Channel for startup message | none | | ||
| 67 | | `ASSISTANT_KEYWORD` | Keyword to trigger AI assistant | `jarvis` | | ||
| 68 | | `COPYPARTY_URL` | File server base URL | `http://localhost:8080` | | ||
| 69 | | `COPYPARTY_PASSWORD` | File server password | none | | ||
| 70 | | `OPENROUTER_API_KEY` | AI API key (for /senator command) | none | | ||
| 71 | |||
| 72 | ## Commands | 53 | ## Commands |
| 73 | 54 | ||
| 74 | ### Music | 55 | Slash commands are autoregistered globally on startup. Some are registered |
| 75 | - `/play` - Play music from file server or an internet audio stream | 56 | under their original Polish verb names to match the UI expected by existing |
| 76 | - `/stop` - Stop playback | 57 | servers. |
| 77 | - `/join` - Join voice channel | 58 | |
| 78 | - `/loop` - Loop current track | 59 | ### AI |
| 79 | 60 | - `/senator` — chat with the OpenRouter model | |
| 80 | ### Utility | 61 | |
| 81 | - `/search` - Search files on server | 62 | ### Music (songbird) |
| 82 | - `/web` - DuckDuckGo search | 63 | - `/grajcuj` — play from Copyparty search, a direct URL, or an uploaded file |
| 83 | - `/download` - Download video/audio | 64 | - `/stop` — stop playback and leave voice |
| 84 | - `/tts` - Text to speech | 65 | - `/join` — join the caller's voice channel |
| 85 | - `/qr_koduj` / `qr_dekoduj` - QR encode/decode | 66 | |
| 86 | - `/kompresja` - Compress images | 67 | ### TTS |
| 87 | - `/konwersja` - Convert audio/video | 68 | - `/tts` — Google Translate TTS (Polish), sent as a file or played in voice |
| 88 | 69 | ||
| 89 | ## Dependencies | 70 | ### Search & Web |
| 90 | 71 | - `/web` — DuckDuckGo HTML scrape (soon to use 4get) | |
| 91 | - `ffmpeg` - System-wide audio processing | 72 | - `/search` — search Copyparty and return a direct download URL |
| 92 | - `py-cord` - Discord library (due to instable nature of discord's voice features, py-cord has to be installed directly from git) | 73 | - `/download` — fetch media from any yt-dlp-supported URL |
| 74 | |||
| 75 | ### Media Tools | ||
| 76 | - `/compress` (alias `kompresja`) — compress a media attachment to low quality | ||
| 77 | - `/convert` (alias `konwersja`) — convert media between formats | ||
| 78 | |||
| 79 | ### Utilities | ||
| 80 | - `/upload` — push Discord attachments into Copyparty | ||
| 81 | - `/say` — repeat the given text as the bot | ||
| 82 | - `/math` — evaluate an ASCII math expression through `qalc` | ||
| 83 | - `/qr generowanie` / `/qr dekodowanie` — QR encode / decode | ||
| 84 | |||
| 85 | ### Triggers | ||
| 86 | - `/trigger create` — new trigger group | ||
| 87 | - `/trigger add` — add keywords/responses to a group | ||
| 88 | - `/trigger remove` — remove a keyword/response | ||
| 89 | - `/trigger delete` — delete a group | ||
| 90 | - `/trigger list` — list a group's keywords and responses | ||
| 91 | - `/trigger help` — usage info | ||
| 92 | |||
| 93 | ### Cron | ||
| 94 | - `/cron dodaj_audio` — schedule audio playback | ||
| 95 | - `/cron dodaj_wiadomość` — schedule a periodic message | ||
| 96 | - `/cron pokaż` — list all cron jobs | ||
| 97 | - `/cron usuń` — remove a cron job | ||
| 98 | - `/cron pauza` — pause a job | ||
| 99 | - `/cron wznów` — resume a job | ||
| 100 | |||
| 101 | ### Message Context Menu | ||
| 102 | - "Wyślij załączniki" (right-click message) — upload attachments to Copyparty | ||
| 103 | - "kompresja" (right-click message) — compress all attachments | ||
| 104 | |||
| 105 | ## Architecture | ||
| 106 | |||
| 107 | The runtime is organised around a shared `Data` struct (poise `user_data`) | ||
| 108 | that holds the DB pool, HTTP client, Copyparty client, voice manager, the | ||
| 109 | in-memory trigger cache, autocomplete cache, and per-guild music track handles. | ||
| 110 | |||
| 111 | - `src/main.rs` — boot: tracing, dotenvy, Config, DB pool, framework, cron task | ||
| 112 | - `src/config.rs` — env-driven `Config` + variable validation | ||
| 113 | - `src/commands/` — one module per command group | ||
| 114 | - `src/copyparty/` — Copyparty search/upload client | ||
| 115 | - `src/openrouter/` — OpenRouter chat client | ||
| 116 | - `src/database/` — sqlx pool, migrations, query helpers (6 tables) | ||
| 117 | - `src/voice/` — `VoiceManager`, mp3 → songbird input | ||
| 118 | - `src/events/` — `handle_ready`, voice-state, message (trigger matching) | ||
| 119 | - `src/tasks/` — 30s cron scheduler poll loop | ||
| 120 | - `src/lang.rs` — user-facing Polish strings | ||
| 121 | |||
| 122 | All temporary files go through `crate::config::TEMP_PATH` | ||
| 123 | (`/tmp/senator_sperma`). | ||
