How yuanxiaona9/harunabot2 works
This is an asynchronous QQ bot that receives OneBot events over WebSocket, parses and routes messages to registered command or notice handlers, and sends replies through the OneBot HTTP API. A major domain workflow manages game-center records and reports or queries headcounts, using PostgreSQL and a name cache. Other handlers provide image/emoji, games, help, plus-one, and group-notice behavior. The excerpts show key routing, initialization, database, and reply paths; links for unsampled handler behavior are limited to registration references in the SOURCE INDEX.
Main entry points: handler_regin.rs Handler registration · postgres_db.rs PostgreSQL connection · msg_reply.rs Reply composition · qq_link.rs QQ transport
Components 24
Runtime and routing
- Application startup
src/main.rs - QQ transport
src/qq_link.rs - Message loop
src/msg_sys/msg_sys.rs - Event analysis
src/msg_sys/msg_analysis.rs - Handler registration
src/msg_sys/handler_regin.rs - Handler initialization
src/msg_sys/handler_init.rs - Reply composition
src/msg_sys/msg_reply.rs
Game-center domain
- Game-center commands
src/msg_sys/func_msg/game_center_manage.rs - Record management
src/msg_sys/func_msg/game_center_manage - Group center listing
src/msg_sys/func_msg/game_center_manage/gcm_query_gc.rs - Headcount reports
src/msg_sys/func_msg/gc_query_report.rs - Headcount query
src/msg_sys/func_msg/gc_query_report/gcqr_query.rs
Bot features
- Emoji and images
src/msg_sys/func_msg/emoji_photo.rs - Emoji speech
src/msg_sys/func_msg/emoji_say.rs - Games
src/msg_sys/func_msg/ttt.rs - Help and play
src/msg_sys/func_msg/help.rs - Plus-one command
src/msg_sys/func_msg/plusone.rs - Group notices
src/msg_sys/func_notice/group_increase.rs
State and integrations
- Feature configuration
src/msg_sys/func_config.rs - PostgreSQL connection
src/msg_sys/func_mod/postgres_db.rs - Game-center name cache
src/msg_sys/func_mod/gc_name.rs - Plus-one state
src/msg_sys/func_mod/plusone_data.rs
Other components
- QQ users
- OneBot service
Connections 39
- QQ users → OneBot service: sends events
- OneBot service → QQ transport: streams events
src/qq_link.rs - Application startup → QQ transport: starts transport
src/main.rs - Application startup → Message loop: starts processing
src/main.rs - QQ transport → Message loop: forwards events
src/main.rs - Message loop → Event analysis: dispatches events
src/msg_sys/msg_sys.rs - Event analysis → Handler registration: reads handlers
src/msg_sys/msg_analysis.rs - Handler registration → Handler initialization: supplies handlers
src/msg_sys/handler_init.rs - Handler initialization → Handler registration: registers handlers
src/msg_sys/handler_regin.rs - Application startup → Feature configuration: loads configuration
src/main.rs - Event analysis → Reply composition: sends error replies
src/msg_sys/msg_analysis.rs - Reply composition → QQ transport: uses HTTP client
src/msg_sys/msg_reply.rs - QQ transport → OneBot service: posts replies
src/qq_link.rs - Handler registration → Game-center commands: registers
src/msg_sys/handler_regin.rs - Handler registration → Headcount reports: registers
src/msg_sys/handler_regin.rs - Handler registration → Emoji and images: registers
src/msg_sys/handler_regin.rs - Handler registration → Emoji speech: registers
src/msg_sys/handler_regin.rs - Handler registration → Games: registers
src/msg_sys/handler_regin.rs - Handler registration → Help and play: registers
src/msg_sys/handler_regin.rs - Handler registration → Plus-one command: registers
src/msg_sys/handler_regin.rs - Handler registration → Group notices: registers
src/msg_sys/handler_regin.rs - Game-center commands → Record management: dispatches subcommands
src/msg_sys/func_msg/game_center_manage.rs - Game-center commands → Group center listing: dispatches subcommand
src/msg_sys/func_msg/game_center_manage.rs - Headcount reports → Headcount query: dispatches subcommands
src/msg_sys/func_msg/gc_query_report.rs - Game-center commands → PostgreSQL connection: initializes tables
src/msg_sys/func_msg/game_center_manage.rs - Record management → PostgreSQL connection: uses database
src/msg_sys/func_msg/game_center_manage/gcm_add_name.rs - Record management → Game-center name cache: uses name cache
src/msg_sys/func_msg/game_center_manage/gcm_add_name.rs - Group center listing → PostgreSQL connection: queries records
src/msg_sys/func_msg/game_center_manage/gcm_query_gc.rs - Headcount reports → PostgreSQL connection: checks database readiness
src/msg_sys/func_msg/gc_query_report.rs - Headcount reports → Game-center name cache: checks cache readiness
src/msg_sys/func_msg/gc_query_report.rs - Headcount query → PostgreSQL connection: queries headcounts
src/msg_sys/func_msg/gc_query_report/gcqr_query.rs - Headcount query → Game-center name cache: resolves center name
src/msg_sys/func_msg/gc_query_report/gcqr_query.rs - Game-center name cache → PostgreSQL connection: loads names
src/msg_sys/func_mod/gc_name.rs - PostgreSQL connection → Feature configuration: reads connection settings
src/msg_sys/func_mod/postgres_db.rs - Plus-one command → Plus-one state: uses state
src/msg_sys/func_msg/plusone.rs - Emoji and images → Reply composition: composes messages
src/msg_sys/func_msg/emoji_photo.rs - Emoji speech → Reply composition: composes messages
src/msg_sys/func_msg/emoji_say.rs - Help and play → Reply composition: sends replies
src/msg_sys/func_msg/help.rs - Group notices → Reply composition: sends notice replies
src/msg_sys/func_notice/group_increase.rs