LAPLACE Rinnegan can be configured via a JSON configuration file, environment variables, and command-line flags.
Configuration Precedence
Settings are merged in the following order, from lowest to highest priority:
- Built-in defaults (
DEFAULT_CONFIG) - Configuration file (
rinnegan.config.jsonin the working directory by default, or the path passed to--config <path>) - Environment variables (
LOGIN_SYNC_*,RINNEGAN_*) - Command-line flags (CLI options)
Example Configuration File
Create rinnegan.config.json in your working directory (see apps/rinnegan/rinnegan.config.example.json in the repository):
{
"logDir": "logs",
"reportDir": "reports",
"timeZone": "Asia/Shanghai",
"storeUrl": "sqlite:data/rinnegan.sqlite",
"detector": {
"windowMs": 3600000,
"suspectScore": 60,
"spamScore": 90
},
"live": {
"url": "ws://localhost:8080",
"rooms": [25034104],
"includeMirror": false
},
"loginSync": {
"baseURL": "https://login-sync.laplace.cn",
"refreshMinutes": 30
},
"loginFile": "data/bilibili-login.json",
"ban": {
"dryRun": false,
"patterns": ["loop", "burst", "template", "blend"],
"hours": -1,
"expireAfterHours": 0,
"reasonTemplate": "独轮车 ×{count}:{sample}",
"exemptUids": [],
"exemptGuards": false,
"exemptMedalLevel": 0,
"maxPerMinute": 5,
"maxPerSession": 100
},
"unbanSpendCny": 0,
"ai": {
"mode": "off",
"provider": "jev",
"protocol": "openrouter",
"threshold": 0.8,
"maxPerHour": 120
}
}RinneganConfig Reference
Prop
Type
BanConfig Reference
Prop
Type
Environment Variables
Keep tokens and API keys in environment variables rather than committing them to version control:
| Environment Variable | Config Path | Description |
|---|---|---|
LOGIN_SYNC_TOKEN | loginSync.token | uuid@password token from the LAPLACE Login Sync browser extension. |
LOGIN_SYNC_URL | loginSync.baseURL | Custom Login Sync server URL (leave empty to use the official public server). |
LOGIN_SYNC_AUTH_KEY | loginSync.authKey | Authentication key for a self-hosted Login Sync server. |
RINNEGAN_LOGIN_FILE | loginFile | File path where rinnegan login stores QR code login cookies (default data/bilibili-login.json). |
RINNEGAN_EVENT_URL | live.url | LAPLACE Event Fetcher or Event Bridge WebSocket URL. |
RINNEGAN_EVENT_TOKEN | live.token | Event source bridge token (BRIDGE_TOKEN on Fetcher or --auth on Bridge). |
RINNEGAN_ROOMS | live.rooms | Comma-separated list of live room IDs to monitor. |
RINNEGAN_STORE_URL | storeUrl | Ban store connection URL (sqlite:<path>, postgres://…, redis://…, or memory:). |
RINNEGAN_LOG_DIR | logDir | Directory for daily JSONL audit logs (default logs). |
RINNEGAN_REPORT_DIR | reportDir | Directory for offline analysis reports (default reports). |
RINNEGAN_TIMEZONE | timeZone | Time zone used to parse --since/--until and display timestamps (default Asia/Shanghai, UTC+8). |
RINNEGAN_AI_MODE | ai.mode | AI review mode: off, confirm, or assist. |
RINNEGAN_AI_PROVIDER | ai.provider | AI review provider: jev or llm. |
RINNEGAN_AI_PROTOCOL | ai.protocol | jev endpoint protocol: openrouter or typesafe. |
RINNEGAN_AI_BASE | ai.apiBase | Base URL for the AI API. |
RINNEGAN_AI_API_KEY | ai.apiKey | API key for the AI review provider. |
RINNEGAN_AI_MODEL | ai.model | AI model identifier. |
RINNEGAN_AI_THRESHOLD | ai.threshold | Probability threshold ((0, 1], default 0.8) required for the AI reviewer to approve a ban. |
CLI Options Summary
Common Options
| Option | Description |
|---|---|
-c, --config <file> | Path to JSON configuration file (defaults to ./rinnegan.config.json if present). |
-r, --room <ids> | Filter to these room IDs (comma-separated or repeated). |
--window <minutes> | Sliding detection window in minutes (default 60). |
--spam-score <n> | Score threshold for spam verdict (default 90). |
--suspect-score <n> | Score threshold for suspect verdict (default 60). |
--include-mirror | Also evaluate mirrored cross-room danmaku. |
--log-dir <dir> | Audit log directory (default ./logs). |
--timezone <zone> | Time zone for --since/--until and displayed timestamps, default Asia/Shanghai (UTC+8). |
--login-sync-token <u@p> | LAPLACE Login Sync uuid@password token (takes precedence over QR login). |
--login-sync-url <url> | Custom Login Sync server URL (default https://login-sync.laplace.cn). |
--login-file <path> | QR login cookie file path (default data/bilibili-login.json). |
--store <url> | Ban store connection URL (default sqlite:data/rinnegan.sqlite). |
-h, --help | Print command help. |
-v, --version | Print version. |
offline Options
| Option | Description |
|---|---|
--since <time> | Only analyze messages at or after this time (such as 2026-10-20 20:00). |
--until <time> | Only analyze messages at or before this time. |
--top <n> | Maximum users shown per category in the terminal summary (default 30). |
--samples <n> | Message samples shown per cluster in the terminal summary (default 3). |
--spam-only | Show only spam users in terminal output, hiding suspect and 手动融入 users. |
--report-dir <dir> | Report output directory (default ./reports). |
--no-report | Skip writing JSON, Markdown, and HTML report files. |
live, bans, and unban Options
| Option | Description |
|---|---|
-u, --url <ws> | live event source WebSocket URL (default ws://localhost:9696; Event Fetcher bridge mode is typically ws://host:8080). |
-t, --token <token> | live event source token (BRIDGE_TOKEN on Fetcher or --auth on Bridge). |
--dry-run | live / unban simulate without calling the ban or unban API. |
--patterns <list> | live patterns eligible for banning: loop,burst,template,blend (all by default; flood is never banned). |
--ban-hours <n> | live bilibili ban duration in hours (-1 for permanent). |
--expire-after <hours> | live automatically lift bans placed by Rinnegan after n hours (0 disables). |
--reason <template/text> | live ban reason template, or unban manual lift reason. |
--exempt-uid <ids> | live whitelisted user UIDs (comma-separated or repeated). |
--exempt-guards | live exempt guard members (舰长 / 提督 / 总督). |
--exempt-medal <n> | live exempt users wearing a fan medal at or above level n (0 disables). |
--max-per-minute <n> | live safety brake: maximum bans per room per minute (default 5). |
--max-bans <n> | live safety brake: maximum bans per run (default 100). |
--unban-spend <cny> | live automatically lift a user's ban once they spend this much CNY in the room (0 disables). |
--ai <mode> | live AI review mode: off, confirm, assist. |
--ai-provider <kind> | live AI review engine: jev (default) or llm. |
--ai-protocol <proto> | live jev endpoint protocol: openrouter (default) or typesafe. |
--ai-model <id> / --ai-base <url> / --ai-threshold <0-1> | live AI model identifier, base URL, and approval threshold (default 0.8). |
--verbose / --status <sec> | live log every suspect change / status line interval in seconds (default 60, 0 disables). |
--remote / --local / --limit <n> | bans show bilibili silent list only / local records only / local row limit (default 100). |
--uid <ids> / --session <id> | unban target user UIDs, or revert every real ban from an audit session. |
Audit Log and Credential Scrubbing
During every run, Rinnegan appends structured records synchronously to a daily JSONL audit file at logs/audit-YYYY-MM-DD.jsonl.
Record Format and Event Types
Each JSON line includes standard metadata along with the event payload:
ts: ISO 8601 timestampsession: UUID of the current run sessionmode: Execution mode (offline,live, oradmin)event: Lifecycle event identifier:- Session & Rooms:
session-start,session-error,session-end,room-ready,room-unmanaged,connection,credentials-refresh - Detection & Review:
detection,review,review-error,veto - Enforcement & Unban:
ban,ban-failed,skip,brake,unban,unban-failed,spend,user-block - Errors:
lifecycle-error,store-error,enforce-error
- Session & Rooms:
Automatic Credential Redaction
Before writing any line to disk, the audit logger recursively traverses the record and replaces the value of any key matching the following names (case-insensitive, ignoring underscores and hyphens) with "[redacted]", so audit logs can be safely archived or shared for debugging:
cookie,cookies,sessdata,bili_jct,csrf,csrf_tokentoken,refreshtoken,refresh_tokenapikey,api_key,authkey,auth_key,password
Last updated on November 29, 2026