Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Runtime data (databases, vectors, stored action GIFs) is mounted by docker-compose
# (./data:/app/data); keeping it out of the build context and the image.
data/
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ TAVILY_API_KEY=
# --- Server Wrapped (/wrapped, server_wrapped tool, automatic recaps) ---
# WRAPPED_ENABLED=true
# WRAPPED_HOUR=10 # Brasília hour automatic recaps go out (Mondays weekly / the 1st monthly; turn on with /config servidor)
# --- Action GIFs (/hug, /kiss, /slap…: an anime GIF of someone doing it to someone) ---
# ACTIONS_ENABLED=true
# ACTIONS_DB_PATH=data/actions.db
# ACTIONS_STORE_GIFS=true # keep every distinct GIF; uploaded as an attachment when no GIF API answers
# ACTIONS_GIFS_DIR=data/action_gifs
# ACTIONS_PING_TARGET=true # notify the person on the receiving end
# ACTIONS_COOLDOWN_SECONDS=5 # between two actions of one person
# ACTIONS_BOT_REPLY=true # doing an action to the bot gets an answer in character (one chat turn)
# ACTIONS_TOOL_ENABLED=true # send_action_gif: the bot does actions itself when asked or when it fits
# nekos.best refuses requests without "AppName (contact)": an email, site, repository or bot invite link.
# Empty = the bot's name and its invite link.
# ACTIONS_USER_AGENT=QuillBot (https://github.com/you/your-fork)
# --- Voice calls (/voz entrar | sair: real-time voice conversation in voice channels) ---
# Speech-to-speech with Qwen-Audio realtime (Alibaba Cloud Model Studio). Needs libopus on the host.
# Servers also opt in: /config servidor opcao:Conversa por voz valor:sim
Expand Down
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Built with [discord.py](https://discordpy.readthedocs.io/) + RAG (Retrieval-Augm
| **Channel Summaries** | `/resumo` and natural-language "o que perdi?" — map-reduce summaries of a channel or thread over any period, with jump links and permission checks |
| **Monitors** | Standing triggers (channels, authors, mentions of a user, a content regex) that call the bot on matching messages; it answers like a mention, knows a monitor sent it, and may stay silent. Managed with `/monitor` or by asking the bot |
| **Voice Calls** | `/voz entrar`: the bot joins your voice channel and talks in real time (speech-to-speech with Qwen-Audio realtime) — hears everyone in the call, stops when talked over, optionally writes the conversation in the call's chat. Off unless configured, and each server opts in |
| **Action GIFs** | `/hug`, `/kiss`, `/slap`, `/pat` and 23 more: an anime GIF of you doing it to someone, who can return it with a button. Done to the bot, it answers in character; asked ("dá um abraço no Bruno"), it does them itself. Counts per pair ("Ana já abraçou Bruno 5 vezes") |
| **Persistent Memory** | The bot remembers: atomic facts about the server and its members, auto-injected into every conversation, with inline LLM writes, pinning, dedupe, full audit history and admin control. Each memory records who said it — a fact about someone told by someone else is shown as a report ("segundo Fulano") |

All AI responses are in **Brazilian Portuguese**.
Expand Down Expand Up @@ -228,6 +229,25 @@ A recap of the server over a period (`semana` = 7 days, default; `mes`; `ano`; o
- **Data:** messages from the history index; reactions from a `reactions` table recorded live since this version (no backfill), also queryable with `sql_history`
- Set `WRAPPED_ENABLED=false` to remove the command, the tool and the automatic posts

#### `/hug`, `/kiss`, `/slap`… — Action GIFs
`/<ação> usuario:@Pessoa` posts an anime GIF of you doing the action to that person (`cogs/actions.py`, `core/action_gifs.py`): `🤗 **Ana** abraçou @Bruno!`, the GIF in an embed, and a footer with the count for that pair and the anime it's from.

| Kind | Commands | Button |
|---|---|---|
| Affection | `/hug`, `/kiss`, `/peck`, `/blowkiss`, `/pat` (headpat), `/cuddle`, `/nuzzle`, `/lappillow`, `/handhold`, `/handshake`, `/highfive`, `/brofist`, `/wave`, `/cheers`, `/feed` | Retribuir |
| Playful | `/wink`, `/stare`, `/lick`, `/poke`, `/pinch`, `/tickle`, `/bite`, `/bonk` | Devolver |
| Rough | `/slap`, `/punch`, `/kick`, `/yeet` | Revidar |

- **Doing it back:** the button under the GIF works for its target only, once, for 10 minutes; it posts the same action the other way ("… de volta!"), without a button of its own
- **GIFs:** each action's sources in order — [nekos.best](https://nekos.best) (it also names the anime) and [otakugifs.xyz](https://otakugifs.xyz) (`blowkiss` falls back to its `airkiss`; `lick`, `nuzzle`, `brofist`, `cheers` and `pinch` exist only there; `peck`, `lappillow`, `handshake`, `highfive`, `feed`, `bonk`, `kick` and `yeet` only on nekos.best). Only GIFs on those hosts are posted. nekos.best refuses requests without a User-Agent naming the app and a contact: by default the bot's name and invite link, or `ACTIONS_USER_AGENT`
- **When no API answers:** every distinct GIF the APIs return is recorded (`ACTIONS_DB_PATH`, no limit), and its file is downloaded once in the background into `ACTIONS_GIFS_DIR`, named by its SHA-256 so identical GIFs are kept once (two downloads at a time; a failed one is retried the next time that GIF is served; only real GIFs up to 10 MiB, Discord's upload limit). When every source fails, a stored file is uploaded with the message and the embed shows it (`attachment://hug.gif`), so nothing has to be hosted; without files, a stored URL is reused; with neither, the action goes out as text. A GIF averaged about 0.9 MB in testing, so a full set of a few thousand GIFs is a few GB. `ACTIONS_STORE_GIFS=false` keeps only the URLs. nekos.best's terms allow caching its responses for private use only and forbid rehosting, so storing and re-uploading its GIFs is the operator's call
- **Doing it to the bot:** after the GIF, the bot answers in character, like a mention — a few words, a reaction on the GIF, doing it back with `send_action_gif`, or nothing. It costs the person one turn of their `CHAT_USER_BUDGET` (over it, the GIF stands alone), and replying to the answer continues the conversation. Not in channels where `respond` is `off`; `ACTIONS_BOT_REPLY=false` turns it off
- **The bot doing it:** the `send_action_gif` tool (chat profile) — when asked ("dá um abraço no Bruno", "bate nele") or when it fits its personality, at most once per answer; the GIF goes out before the answer, with a button for the person to do it back. `ACTIONS_TOOL_ENABLED=false` removes it
- **Yourself:** affection actions come from the bot instead ("Ninguém merece fazer isso sozinho: **QuillBot** abraçou @Ana!"); the others are refused
- **Pings:** the target is notified (`ACTIONS_PING_TARGET=false` for none); bots never are. Other bots can be targets, without a button
- **Limits:** one action per person every `ACTIONS_COOLDOWN_SECONDS` (all commands together); off per channel or server with `/config … actions não`
- `/help` lists them on one line; `ACTIONS_ENABLED=false` removes the commands and the tool

#### `/config` — Server and channel settings *(Manage Server)*
| Subcommand | Description |
|---|---|
Expand All @@ -243,6 +263,7 @@ A recap of the server over a period (`semana` = 7 days, default; `mes`; `ano`; o
| `threads` | channel | `auto`, `always`, `never` |
| `reply_style` | channel | `auto`, `plain`, `embed` (default `CHAT_REPLY_STYLE`) |
| `log_detection` | channel | react to log links, `.log`/`.txt` files and Spark links |
| `actions` | channel | `/hug`, `/slap`… and the bot's own action GIFs (default on) |
| `instructions` | channel | text the model follows in that channel ("seja direto e técnico", "aqui é papo livre") |
| `aliases` | server | extra names the bot answers to, comma-separated |
| `wrapped`, `wrapped_channel` | server | automatic Wrapped: `off`/`weekly`/`monthly` and where |
Expand Down Expand Up @@ -458,6 +479,7 @@ QuillBot/
│ ├── discord_text.py # Mentions/pings, identity block, canonical message lines, splitting
│ ├── chat_threads.py # When conversations move into threads, the open_thread tool, bot-thread detection
│ ├── message_media.py # Stickers, GIFs, custom emojis, reactions, the add_reaction tool
│ ├── action_gifs.py # Action GIFs: the actions, GIF APIs with fallbacks, counts, wording
│ ├── image_store.py # Persisted, re-encoded images for vision
│ ├── tavily_tools.py # Tavily web_search / web_extract
│ ├── local_inference.py# Single-thread executor for local models
Expand All @@ -473,6 +495,7 @@ QuillBot/
│ ├── persona.py # /persona, the persona_update tool, change log with Revert
│ ├── wrapped.py # /wrapped, server_wrapped tool, automatic weekly/monthly recaps
│ ├── voice.py # /voz entrar | sair — real-time voice calls
│ ├── actions.py # /hug, /kiss, /slap…, the return button, send_action_gif, the bot answering actions
│ ├── docs_rag.py # Docs RAG — indexing, search, reranking, /reindex, search_docs/search_plugins tools
│ ├── history_rag.py # Server-wide history RAG — backfill, live ingestion, reactions, history tools, Wrapped stats
│ ├── log_analyzer.py # Passive log detection, pattern matching, /analyze, file upload to mclo.gs
Expand All @@ -493,6 +516,8 @@ QuillBot/
├── settings.db # /config settings
├── persona.db # Personality sections + history
├── conversations.db # Conversations (handles, triggers, episode state)
├── actions.db # Action counts per pair, every GIF URL seen and its stored file
├── action_gifs/ # Stored GIF files (<sha256>.gif), uploaded when no GIF API answers
├── lore.db # Legacy lore encyclopedia (kept as migration source)
└── history/ # Per-guild history stores
```
Expand Down Expand Up @@ -706,6 +731,20 @@ cp .env.example .env # if available, otherwise create .env manually
| `WRAPPED_ENABLED` | `true` | `/wrapped`, the `server_wrapped` tool and automatic recaps |
| `WRAPPED_HOUR` | `10` | Brasília hour automatic recaps are posted (Mondays / the 1st) |

### Action GIFs

| Variable | Default | Description |
|---|---|---|
| `ACTIONS_ENABLED` | `true` | `/hug`, `/kiss`, `/slap`… and the `send_action_gif` tool |
| `ACTIONS_DB_PATH` | `data/actions.db` | Counts per pair and every GIF URL seen |
| `ACTIONS_STORE_GIFS` | `true` | Keep a copy of every distinct GIF, uploaded as an attachment when no GIF API answers |
| `ACTIONS_GIFS_DIR` | `data/action_gifs` | Where those copies go |
| `ACTIONS_PING_TARGET` | `true` | Notify the person on the receiving end |
| `ACTIONS_COOLDOWN_SECONDS` | `5` | Between two actions of one person (all commands together) |
| `ACTIONS_BOT_REPLY` | `true` | Doing an action to the bot gets an answer in character (one chat turn) |
| `ACTIONS_TOOL_ENABLED` | `true` | The bot can do actions itself (`send_action_gif`) |
| `ACTIONS_USER_AGENT` | bot name + invite link | User-Agent for the GIF APIs. nekos.best asks for `AppName (contact)` — an email, site, repository or bot invite — and refuses requests without one |

### Voice Calls

`/voz` exists only when `VOICE_ENABLED=true`, both `VOICE_API_KEY` and `VOICE_REALTIME_URL` are set, and libopus is installed (the startup log says which one is missing). Servers then opt in with the `voice` setting.
Expand Down Expand Up @@ -780,7 +819,7 @@ Cog load order doesn't matter: the router decides who sees a message, not the or
docker compose up --build -d
```

- Uses `python:3.11-slim`, persists `data/` via volume mount, reads config from `.env`.
- Uses `python:3.11-slim`, persists `data/` via volume mount, reads config from `.env`. `data/` (databases, stored action GIFs) is in `.dockerignore`, so it never goes into the build or the image.

---

Expand All @@ -800,6 +839,7 @@ ruff check . # lint (rules configured in pyproject.toml)

| File | Covers |
|---|---|
| `test_actions.py` | Action GIFs: providers in order and fallbacks (stored file uploaded as an attachment, stored URL, text), every distinct GIF kept, files saved once per content and retried after a failed download, non-GIFs and oversized files refused, refused hosts, counts, wording, the return button (target only, once, back the other way), pings, cooldown and self-actions, the bot answering actions done to it (and returns of its own), the `send_action_gif` tool, the engine's answer starting a conversation |
| `test_api_logger.py` | Request logging for aiohttp/httpx/httpx2, redaction, body capture, inbound interactions (runs in its own process) |
| `test_attribution.py` | Author tags on every question, speaker changes marked in the tag (verbatim and compact replay), the conversation block naming who speaks now, byte-identical replay of per-turn blocks, memory block labels and person-memory rules |
| `test_channel_context_images.py` | Images from automatically fetched channel context |
Expand Down
3 changes: 3 additions & 0 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ Every message goes through one router (`core/router.py`): passive observers (his
| `/resumo` | Summarize what happened in a channel | Yes |
| `/wrapped` | Server recap: who talked most, channels, emojis… | Optional** |
| `/config` | Server and channel settings (Manage Server) | No |
| `/hug`, `/kiss`, `/slap`… | Anime GIF of you doing it to someone (27 actions) | No*** |
| `/persona` | The bot's personality on this server (editing needs Manage Server) | No |
| `/memory`, `/monitor`, `/schedule` | Memories, standing triggers, scheduled tasks | Yes |
| `/analyze` | Analyze a server log with AI (mclo.gs, pastebin, or file) | Yes |
Expand All @@ -231,6 +232,7 @@ Every message goes through one router (`core/router.py`): passive observers (his

*`/docs` with a query delegates to RAG search if available, otherwise shows a link.
**The numbers come from the history index; the AI only writes the intro.
***The GIFs come from nekos.best and otakugifs.xyz; the AI only answers when the action is done to the bot.

---

Expand Down Expand Up @@ -261,6 +263,7 @@ QuillBot/
│ ├── server_config.py# /config
│ ├── persona.py # /persona and the bot's personality per server
│ ├── wrapped.py # /wrapped and automatic recaps
│ ├── actions.py # /hug, /kiss, /slap… action GIFs
│ ├── docs_rag.py # RAG pipeline: indexing, search, /reindex, search_docs tool
│ ├── log_analyzer.py # Log analysis: pattern matching, /analyze, AI analysis
│ ├── plugins.py # External API commands: /plugin, /status, /changelog
Expand Down
Loading