NapCat plugin for group-message moderation. The plugin checks group text messages against:
- custom words from plugin config
- the bundled local dictionary (
dictionary.txt/dictionary.b64) - an optional OpenAI-compatible guard API
Unsafe messages are withdrawn, optionally announced in the group, counted per user, and batch-reported to configured admins.
src/
index.ts Plugin lifecycle entry
config.ts default config and NapCat config UI
core/state.ts config persistence, stats, group enable rules
handlers/message-handler.ts message moderation and NapCat action helpers
services/censor-service.ts dictionary loading and guard API checks
services/api-service.ts WebUI API routes
webui/ React WebUI
dictionary.txt local plain-text dictionary
dictionary.b64 local base64 dictionary fallback
The TypeScript source is the canonical implementation. dist/index.mjs is generated by Vite.
pnpm install
pnpm run typecheck
pnpm run buildBuild output:
dist/
index.mjs
package.json
dictionary.txt
dictionary.b64
webui/
| Field | Purpose |
|---|---|
enabled |
global plugin switch |
adminIds |
comma-separated admin QQ IDs for private reports |
censorGroups |
comma-separated group IDs to moderate |
censorWords |
custom comma/newline-separated words |
maxViolations |
number of violations before auto-ban; 0 disables banning |
banDurationSeconds |
auto-ban duration |
reportBatchSize |
number of violations to batch before admin report |
showFilterNotice |
whether to notify the group after withdrawing a message |
dictionaryUrl |
remote base64 dictionary fallback |
guardApiUrl |
OpenAI-compatible chat completions endpoint |
guardTimeoutMs |
guard API timeout |
Group-level enable/disable settings from the WebUI override censorGroups.
The GitHub Actions release workflow builds the TypeScript project, packages dist/, and uploads napcat-plugin-censor.zip.