Files
kingston 26a0728e14 docs: move cog documentation into the wiki and stub the README
The root README carried the full ten cog manual while the wiki held the
authoritative pages. Point the repository at the wiki, keep only install and
catalog basics in the README, and remove the per cog documents that are now
folded into wiki source under wiki/.
2026-11-03 12:54:42 -06:00

95 lines
4.5 KiB
Markdown

# Development
## Layout
Each cog is a Python package at the repository root:
```
albumoftheday/
__init__.py
albumoftheday.py
info.json
assistant/
autoroom/
__init__.py
abc.py
autoroom.py
c_autoroom.py
c_autoroomset.py
pcx_lib.py
pcx_template.py
pcx_template_test.py
deadman/
imagegrab/
playitstatus/
renamer/
transcribe/
ttstoy/
__init__.py
ttstoy.py
morshutalk_engine.py
vox_engine.py
sfx/
dectalk-server/
vox-server/
morshu-server/
ytaudio/
```
Every `__init__.py` reads `info.json` for `__red_end_user_data_statement__` and exposes `async def setup(bot)`. YTAudio and AutoRoom do extra work in setup: YTAudio starts the Lavalink connect task, and AutoRoom awaits `initialize()` so config migrations run before the cog accepts commands.
## Manifest fields
`info.json` holds `author`, `description`, `install_msg`, `short`, `end_user_data_statement`, `requirements`, and optionally `hidden` and `disabled`. Red reads `requirements` at install time. A package missing from `requirements` fails at runtime when the cog is first used.
## Command conventions
- Groups use `invoke_without_command` when running the bare group should print a summary rather than an error.
- Settings commands use `@checks.admin_or_permissions(manage_guild=True)` or `@commands.is_owner()`. Assistant and YTAudio are the exceptions with mostly ungated commands.
- Cooldowns and concurrency limits are applied with `@commands.cooldown` and `@commands.max_concurrency`. Transcribe uses a per-user cooldown and a single global concurrency slot.
- Long responses are chunked to fit Discord's 2000 character limit rather than truncated mid-message.
## Config identifiers
Identifiers are stable and must not change without a migration, or every guild loses its settings.
| Cog | Identifier |
|---|---|
| AlbumOfTheDay | `0xA1B00FDA` |
| Assistant | `987654321` |
| AutoRoom | `1224364860` |
| Deadman | `918273645` |
| PlayitStatus | `1234567890` |
| Renamer | `182736451` |
| Transcribe | `481516234` |
| TtsToy | `0x0A0A0A0A` |
| YTAudio | `0x5954415544494F` |
AutoRoom also uses schema migrations keyed on `schema_version` in global config. The current schema has removed the guild level `member_role`. Member roles are now derived from which roles can connect to the AutoRoom Source.
## Tests
`autoroom/pcx_template_test.py` is the only test file in the repository. It covers the Jinja subset implemented in `pcx_template.py`, including conditionals, filters and duplicate handling. Run it with:
```
python -m unittest autoroom.pcx_template_test
```
No cog has integration tests, and nothing tests Red command behavior, config migrations or the HTTP clients.
## Known defects in the current code
These are documented so the wiki matches the code. They are not fixed here.
- PlayitStatus has no background task. The manifest and older README describe a ten second poller and automatic alerts. Only `[p]playit status` checks the API, and it only posts when a status changed since the last check.
- Assistant advertises vision. The message handler replies that images are unsupported, clears the image list, and then continues with text. The multimodal branch in `_chat` cannot be reached.
- Assistant gates only `setkey`, `baseurl` and `showprompt`. Any member can change the model, temperature, max tokens, system prompt, question mode, and the server chat channel.
- Assistant's `default_search` and pricing table assume a specific provider. The local default model is not in the pricing table, so it sorts last with `pricing unknown`.
- Renamer registers `allowed_roles` per guild and never reads it. All three commands are administrator only.
- Transcribe `translate` fetches replied messages without declaring the Read Message History check that `transcribe` declares. It works if the message is cached, and silently finds no text if the fetch fails.
- Transcribe and Assistant contain literal em dash characters in user-facing strings.
- YTAudio has no permission checks. Any member can skip, stop or change the volume of another member's playback, and any member can disconnect the bot.
- TtsToy's `ffmpeg` concatenation assumes input files share codec parameters. Mixed engines can produce a file with audible discontinuities.
- The TtsToy `[p]ttstoy info` text still mentions a default Chatterbox port of 8004 while the code uses 8099, and lists commands such as `chatterboxurl` that were renamed to `[p]chatterbox url`.
- `ttstoy/stack.json` contains filesystem paths and a session secret for a specific deployment. It is not used by the cog.