Skip to content

XiaoYuan151/napcat-plugin-censor

Repository files navigation

napcat-plugin-censor

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.

Source Layout

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.

Build

pnpm install
pnpm run typecheck
pnpm run build

Build output:

dist/
  index.mjs
  package.json
  dictionary.txt
  dictionary.b64
  webui/

Main Config

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.

Release

The GitHub Actions release workflow builds the TypeScript project, packages dist/, and uploads napcat-plugin-censor.zip.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors