From ec3a1c8eac2a03528a7e34bb1c9b72815e73bba4 Mon Sep 17 00:00:00 2001 From: K2cr2O1 <2221577113@qq.com> Date: Fri, 9 Jan 2026 04:47:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/core-concepts/event-flow.md | 54 ++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/docs/core-concepts/event-flow.md b/docs/core-concepts/event-flow.md index 5d7275e..e38f497 100644 --- a/docs/core-concepts/event-flow.md +++ b/docs/core-concepts/event-flow.md @@ -8,15 +8,51 @@ ```mermaid graph TD - A[OneBot v11 实现端] -- WebSocket Message --> B(core/ws.py); - B -- Raw JSON Data --> C(models/events/factory.py); - C -- Event Object --> D(core/ws.py on_event); - D -- Event Object --> E(core/managers/command_manager.py); - E -- Event & Command Match --> F(core/handlers/event_handler.py); - F -- Matched Handler --> G(plugins/echo.py); - G -- Call API --> H(core/bot.py); - H -- Send Request --> B; - B -- WebSocket Send --> A; + %% 定义样式 + classDef external fill:#e1f5fe,stroke:#01579b,stroke-width:2px; + classDef network fill:#fff9c4,stroke:#fbc02d,stroke-width:2px; + classDef core fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px; + classDef plugin fill:#fce4ec,stroke:#c2185b,stroke-width:2px; + + subgraph External [外部环境] + OneBot[OneBot v11 实现端
(如 NapCatQQ)]:::external + end + + subgraph NeoBot [NEO Bot Framework] + direction TB + + subgraph Network [网络接入层] + WS[WebSocket 连接
core/ws.py]:::network + end + + subgraph Processing [核心处理层] + Factory[事件工厂
models/events/factory.py]:::core + Dispatcher[命令管理器
core/managers/command_manager.py]:::core + Handler[事件处理器
core/handlers/event_handler.py]:::core + BotAPI[Bot API 封装
core/bot.py]:::core + end + + subgraph Plugins [业务插件层] + UserPlugin[用户插件
plugins/*.py]:::plugin + end + end + + %% 事件上报流程 (实线) + OneBot -- 1. WebSocket 消息 --> WS + WS -- 2. 原始 JSON --> Factory + Factory -- 3. Event 对象 --> WS + WS -- 4. 分发事件 --> Dispatcher + Dispatcher -- 5. 匹配指令/事件 --> Handler + Handler -- 6. 调用处理函数 --> UserPlugin + + %% API 调用流程 (虚线) + UserPlugin -. 7. 调用 bot.send() .-> BotAPI + BotAPI -. 8. 封装 API 请求 .-> WS + WS -. 9. 发送 JSON .-> OneBot + + %% 链接样式 + linkStyle 0,1,2,3,4,5 stroke:#333,stroke-width:2px; + linkStyle 6,7,8 stroke:#666,stroke-width:2px,stroke-dasharray: 5 5; ``` ## 详细步骤