How qingyingx-bot/speaker-statistics-plugin works
This is a Yunzai-Bot group-chat statistics plugin. Its main workflow records messages, persists hourly and aggregate statistics, answers ranking and personal-stat queries, and renders results for users. Separate capabilities cover group analysis and word clouds, Web administration and ranking backgrounds, and configuration management. The README documents these product branches; sampled source confirms database aggregation, configuration, plugin startup, and background administration, but not every command-to-service call, so uncertain wiring is omitted.
Main entry points: DatabaseService.js Statistics database · index.js Plugin startup · WebServer.js Web administration · speaker.js Message listener
Components 24
Message collection
- Message listener
apps/speaker.js - Message recorder
core/MessageRecorder.js - Message collector
core/services/messageCollector.js
Statistics and rendering
- User commands
apps/commands/UserCommands.js - Ranking commands
apps/commands/RankCommands.js - Statistics access
core/DataService.js - Statistics database
core/database/DatabaseService.js - PostgreSQL adapter
core/database/adapters/PostgreSQLAdapter.js - SQLite adapter
core/database/adapters/SQLiteAdapter.js - Result rendering
core/render/TemplateManager.js
Analysis features
- Report commands
apps/commands/ReportCommands.js - Word-cloud commands
apps/commands/WordCloudCommands.js - Report statistics
core/services/StatisticsService.js - AI analyzers
core/services/analyzers/BaseAnalyzer.js - Word-cloud generation
core/services/wordCloudGenerator.js
Administration
- Web administration
core/web/WebServer.js - Background management
core/web/BackgroundAdminController.js - Background storage
core/services/BackgroundService.js
Integration and configuration
- Plugin startup
index.js - Guoba configuration
guoba.support.js - Configuration manager
core/ConfigManager.js
Other components
- Group members
- Yunzai Redis
- Plugin user
Connections 28
- Group members → Message listener: send messages
- Message listener → Message recorder: records messages
- Message recorder → Statistics database: writes statistics
- Message collector → Statistics database: collects messages
- Plugin startup → Statistics database: initializes
- Plugin startup → Web administration: starts
- Plugin startup → Message collector: starts
- Statistics database → PostgreSQL adapter: uses when configured
- Statistics database → SQLite adapter: uses when configured
- Plugin user → User commands: requests statistics
- Plugin user → Ranking commands: requests rankings
- User commands → Statistics access: queries statistics
- Ranking commands → Statistics access: queries rankings
- Statistics access → Statistics database: reads statistics
- User commands → Result rendering: renders results
- Ranking commands → Result rendering: renders rankings
- Report commands → Report statistics: analyzes messages
- Report commands → AI analyzers: requests AI analysis
- Word-cloud commands → Word-cloud generation: generates word clouds
- Plugin user → Report commands: requests analysis
- Plugin user → Word-cloud commands: requests word clouds
- Web administration → Statistics database: queries statistics
- Web administration → Background management: registers routes
- Background management → Background storage: lists and changes backgrounds
- Plugin user → Web administration: opens administration
- Guoba configuration → Configuration manager: manages configuration
- Plugin startup → Configuration manager: loads configuration
- Message listener → Yunzai Redis: uses Redis statistics