How wang-yifan666/qq_chatbot works
This is a QQ group-chat AI bot. QQ message and notice events enter distinct DIRECT, AMBIENT, and POKE handlers; scheduled tasks provide a separate proactive entry point. Authorized requests converge on message perception and prompt construction, then call an LLM provider and return or proactively send a response. Context, personal memory, relationships, persona and knowledge retrieval, and optional web search support that workflow. The README documents the major stages and boundaries; several service implementations were not sampled, so their internal links are omitted where the documented flow does not establish them.
Main entry points: ai_chat.py Direct Chat · context_store.py Chat Context · scheduled_tasks.py Scheduled Tasks · llm_client.py LLM Fallback
Components 28
Events and Access
- Direct Chat
plugins/ai_chat.py - Context Recorder
plugins/context_recorder.py - Ambient Chat
plugins/ambient.py - Poke Handler
plugins/poke.py - Scheduled Tasks
services/scheduled_tasks.py - Group Access
services/group_access.py
Conversation Pipeline
- Message Resolver
services/perception/message_resolver.py - Multimodal Builder
services/perception/multimodal_builder.py - File Reader
services/perception/file_reader.py - Prompt Builder
services/prompt_builder.py
Context and Personalization
- Context Arbitration
services/context_arbitration.py - Interaction Profile
services/interaction_profile.py - Trigger Intensity
services/trigger_intensity.py - Relationship Service
services/relationship_service.py - Personal Memory Retrieval
services/memory_retriever.py - Persona RAG
services/persona_rag.py - Knowledge RAG
services/knowledge_rag.py
Models and Features
- LLM Fallback
services/llm_client.py - Web Search
services/web_search.py - Paint Command
plugins/paint.py - Image Generation
services/image_gen.py - Embedding Backend
services/embedding_backend.py
Persistence
- Chat Context
services/context_store.py - Personal Memory Store
services/personal_memory_store.py - User Store
services/user_store.py - SQLite Database
services/database.py
Other components
- QQ Events
- Cron Scheduler
Connections 42
- QQ Events → Direct Chat: triggers
- QQ Events → Context Recorder: triggers
- QQ Events → Ambient Chat: triggers
- QQ Events → Poke Handler: triggers
- Cron Scheduler → Scheduled Tasks: triggers
- Direct Chat → Group Access: checks access
plugins/ai_chat.py - Context Recorder → Group Access: checks access
plugins/context_recorder.py - Ambient Chat → Group Access: checks access
plugins/ambient.py - Poke Handler → Group Access: checks access
plugins/poke.py - Scheduled Tasks → Group Access: checks access
services/scheduled_tasks.py - Direct Chat → Message Resolver: resolves message
plugins/ai_chat.py - Message Resolver → Multimodal Builder: builds blocks
services/perception/message_resolver.py - Message Resolver → File Reader: reads files
services/perception/message_resolver.py - Direct Chat → Prompt Builder: builds request
plugins/ai_chat.py - Direct Chat → Context Arbitration: arbitrates context
plugins/ai_chat.py - Direct Chat → Interaction Profile: derives profile
plugins/ai_chat.py - Direct Chat → Trigger Intensity: sets intensity
plugins/ai_chat.py - Direct Chat → Relationship Service: reads and updates
plugins/ai_chat.py - Direct Chat → Personal Memory Retrieval: retrieves memory
plugins/ai_chat.py - Direct Chat → Persona RAG: retrieves style
plugins/ai_chat.py - Direct Chat → Knowledge RAG: retrieves knowledge
plugins/ai_chat.py - Scheduled Tasks → Persona RAG: retrieves style
services/scheduled_tasks.py - Prompt Builder → Chat Context: reads context
services/prompt_builder.py - Direct Chat → Chat Context: stores messages
plugins/ai_chat.py - Context Recorder → Chat Context: records messages
plugins/context_recorder.py - Ambient Chat → Chat Context: stores reply
- Poke Handler → Chat Context: stores reply
- Scheduled Tasks → Chat Context: stores reply
services/scheduled_tasks.py - Direct Chat → Personal Memory Store: uses personal data
- Direct Chat → User Store: upserts identity
plugins/ai_chat.py - Chat Context → SQLite Database: reads and writes
services/context_store.py - User Store → SQLite Database: reads and writes
services/user_store.py - Personal Memory Store → SQLite Database: stores memories
- Persona RAG → Embedding Backend: encodes queries
services/persona_rag.py - Knowledge RAG → Embedding Backend: encodes queries
services/knowledge_rag.py - Direct Chat → LLM Fallback: requests response
plugins/ai_chat.py - Ambient Chat → LLM Fallback: requests decision
- Scheduled Tasks → LLM Fallback: requests response
services/scheduled_tasks.py - Poke Handler → LLM Fallback: generates reply
- LLM Fallback → Web Search: runs tool
services/llm_client.py - Paint Command → Image Generation: generates image
plugins/paint.py - Paint Command → Chat Context: stores reply
plugins/paint.py