ForcomeBot 2.2.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,342 @@
1
+ Metadata-Version: 2.4
2
+ Name: ForcomeBot
3
+ Version: 2.2.4
4
+ Summary: FORCOME 康康 - 千寻微信框架Pro与LangBot的中间件
5
+ Project-URL: Homepage, https://github.com/yourname/ForcomeBot
6
+ Project-URL: Documentation, https://github.com/yourname/ForcomeBot#readme
7
+ Project-URL: Repository, https://github.com/yourname/ForcomeBot
8
+ Author-email: Your Name <your@email.com>
9
+ License-Expression: MIT
10
+ Keywords: chatbot,langbot,middleware,onebot,qianxun,wechat
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Framework :: AsyncIO
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Communications :: Chat
19
+ Requires-Python: >=3.10
20
+ Requires-Dist: apscheduler>=3.10.0
21
+ Requires-Dist: fastapi>=0.104.0
22
+ Requires-Dist: httpx>=0.25.0
23
+ Requires-Dist: pydantic>=2.0
24
+ Requires-Dist: python-multipart>=0.0.6
25
+ Requires-Dist: pyyaml>=6.0
26
+ Requires-Dist: uvicorn>=0.24.0
27
+ Requires-Dist: websockets>=11.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: hypothesis>=6.0.0; extra == 'dev'
30
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
31
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # FORCOME 康康
35
+
36
+ 这是一个用于连接千寻微信框架Pro和LangBot的中间件,实现微信消息与LangBot AI对话的双向通信。
37
+
38
+ ## 架构
39
+
40
+ ```
41
+ 微信用户 <-> 千寻框架Pro <-> 本中间件 <-> LangBot (OneBot v11)
42
+ ```
43
+
44
+ ## 功能特性
45
+
46
+ - 支持私聊消息
47
+ - 支持群聊消息(@机器人触发)
48
+ - 支持多轮对话(基于用户ID维护会话)
49
+ - 支持图片消息(发送和接收)
50
+ - 支持语音消息(接收)
51
+ - 支持引用消息
52
+ - 支持拍一拍消息
53
+ - 支持多微信账号
54
+ - 入群欢迎功能
55
+ - 昵称检测功能
56
+ - 定时提醒功能
57
+ - 群发功能(文本、图片、文件、分享链接、小程序)
58
+ - Web管理界面(React前端)
59
+ - 配置热更新
60
+ - 指数退避重连机制
61
+ - API重试机制
62
+ - 状态持久化
63
+
64
+ ## 📦 快速开始
65
+
66
+ ### 方式一:uvx 一键启动(推荐)
67
+
68
+ 需要先安装 [uv](https://docs.astral.sh/uv/getting-started/installation/)
69
+
70
+ ```bash
71
+ # 从 PyPI 一键启动(发布后可用)
72
+ uvx ForcomeBot
73
+
74
+ # 或指定 Python 版本
75
+ uvx --python 3.12 ForcomeBot
76
+ ```
77
+
78
+ 首次运行会自动在当前目录创建 `config.yaml` 配置文件,修改配置后重新运行即可。
79
+
80
+ ### 方式二:从源码使用 uvx 启动
81
+
82
+ ```bash
83
+ # 克隆项目
84
+ git clone https://github.com/yourname/ForcomeBot.git
85
+ cd ForcomeBot
86
+
87
+ # 创建并编辑配置文件
88
+ cp config.example.yaml config.yaml
89
+ # 编辑 config.yaml 填入你的配置
90
+
91
+ # 使用 uvx 从本地源码启动
92
+ uvx --from . ForcomeBot
93
+ ```
94
+
95
+ ### 方式三:pip 安装后启动
96
+
97
+ ```bash
98
+ # 从 PyPI 安装(发布后可用)
99
+ pip install ForcomeBot
100
+
101
+ # 或从源码安装
102
+ git clone https://github.com/yourname/ForcomeBot.git
103
+ cd ForcomeBot
104
+ pip install .
105
+
106
+ # 启动
107
+ ForcomeBot
108
+ ```
109
+
110
+ ### 方式四:直接运行 Python
111
+
112
+ ```bash
113
+ git clone https://github.com/yourname/ForcomeBot.git
114
+ cd ForcomeBot
115
+ pip install -r requirements.txt
116
+ python main.py
117
+ ```
118
+
119
+ ### 配置千寻框架
120
+
121
+ 在千寻框架Pro中设置HTTP事件回调地址为:
122
+
123
+ ```
124
+ http://你的IP:8000/qianxun/callback
125
+ ```
126
+
127
+ ## 访问地址
128
+
129
+ 启动后可访问以下地址:
130
+
131
+ | 地址 | 说明 |
132
+ |------|------|
133
+ | `http://IP:8000/app/` | React管理界面 |
134
+ | `http://IP:8000/docs` | API文档(Swagger) |
135
+ | `http://IP:8000/health` | 健康检查 |
136
+ | `ws://IP:8000/api/ws` | WebSocket实时推送 |
137
+
138
+ ## 配置说明
139
+
140
+ ```yaml
141
+ # 中间件服务配置
142
+ server:
143
+ host: "0.0.0.0"
144
+ port: 8000
145
+
146
+ # 千寻框架配置
147
+ qianxun:
148
+ api_url: "http://127.0.0.1:7777/qianxun/httpapi"
149
+ robot_wxid: "wxid_xxx" # 机器人微信ID
150
+
151
+ # LangBot配置(OneBot v11 WebSocket)
152
+ langbot:
153
+ ws_host: "127.0.0.1"
154
+ ws_port: 2280
155
+ access_token: "" # 可选
156
+
157
+ # 消息限流配置
158
+ rate_limit:
159
+ min_interval: 1 # 最小发送间隔(秒)
160
+ max_interval: 3 # 最大发送间隔(秒)
161
+
162
+ # 消息分段发送
163
+ message_split:
164
+ enabled: false
165
+ separator: "/!"
166
+ min_delay: 1
167
+ max_delay: 3
168
+
169
+ # 过滤配置
170
+ filter:
171
+ ignore_wxids: [] # 忽略的wxid列表
172
+ reply_at_all: false # 是否回复@所有人
173
+
174
+ # 入群欢迎配置
175
+ welcome:
176
+ - target_groups: ["xxx@chatroom"]
177
+ message: "欢迎加入!"
178
+
179
+ # 昵称检测配置
180
+ nickname_check:
181
+ - task_id: "check1"
182
+ enabled: true
183
+ cron: "0 9 * * *"
184
+ target_groups: ["xxx@chatroom"]
185
+ regex: "^[\\u4e00-\\u9fa5]+$"
186
+ message_tpl: "⚠️ @{user} 请修改昵称"
187
+ exclude_users: []
188
+
189
+ # 定时提醒配置
190
+ scheduled_reminders:
191
+ - task_name: "daily_reminder"
192
+ enabled: true
193
+ cron: "0 9 * * *"
194
+ target_groups: ["xxx@chatroom"]
195
+ mention_users: ["all"]
196
+ content: "早上好!"
197
+
198
+ # 日志配置
199
+ logging:
200
+ level: "INFO"
201
+ ```
202
+
203
+ ## 目录结构
204
+
205
+ ```
206
+ forcome-kangkang/
207
+ ├── main.py # 主程序入口
208
+ ├── config.yaml # 配置文件
209
+ ├── config.example.yaml # 配置文件示例
210
+ ├── pyproject.toml # 项目配置
211
+ ├── requirements.txt # Python依赖
212
+ ├── data/ # 持久化数据目录
213
+ │ └── state.json # 状态数据
214
+ ├── src/
215
+ │ ├── __init__.py # 模块导出
216
+ │ ├── models.py # 数据模型
217
+ │ ├── web.py # 旧版Web路由(兼容)
218
+ │ │
219
+ │ ├── core/ # 核心服务层
220
+ │ │ ├── config_manager.py # 配置管理器
221
+ │ │ ├── state_store.py # 状态存储器
222
+ │ │ └── log_collector.py # 日志收集器
223
+ │ │
224
+ │ ├── clients/ # 客户端层
225
+ │ │ ├── qianxun.py # 千寻客户端(带重试)
226
+ │ │ └── langbot.py # LangBot客户端(带重连)
227
+ │ │
228
+ │ ├── handlers/ # 业务处理层
229
+ │ │ ├── message_handler.py # 消息处理器
230
+ │ │ ├── message_parser.py # 消息解析器
231
+ │ │ └── scheduler.py # 定时任务调度器
232
+ │ │
233
+ │ ├── utils/ # 工具模块
234
+ │ │ ├── text_processor.py # 文本处理(换行符、emoji)
235
+ │ │ └── xml_parser.py # XML解析工具
236
+ │ │
237
+ │ └── api/ # API层
238
+ │ ├── routes.py # RESTful API路由
239
+ │ └── websocket.py # WebSocket处理
240
+
241
+ ├── web/ # React前端
242
+ │ ├── src/
243
+ │ │ ├── api/ # API调用
244
+ │ │ ├── components/ # 组件
245
+ │ │ ├── pages/ # 页面
246
+ │ │ └── hooks/ # 自定义hooks
247
+ │ └── dist/ # 构建产物
248
+
249
+ └── tests/ # 测试
250
+ ├── test_infrastructure.py # 基础设施测试
251
+ ├── test_clients.py # 客户端测试
252
+ └── test_handlers.py # 处理器测试
253
+ ```
254
+
255
+ ## 模块说明
256
+
257
+ ### 核心服务层 (src/core/)
258
+
259
+ | 模块 | 说明 |
260
+ |------|------|
261
+ | ConfigManager | 配置管理器,支持热更新、验证、观察者模式 |
262
+ | StateStore | 状态存储器,管理消息去重、图片缓存、ID映射,支持持久化 |
263
+ | LogCollector | 日志收集器,支持WebSocket实时推送 |
264
+
265
+ ### 客户端层 (src/clients/)
266
+
267
+ | 模块 | 说明 |
268
+ |------|------|
269
+ | QianXunClient | 千寻框架HTTP API客户端,带自动重试(最多3次) |
270
+ | LangBotClient | LangBot OneBot v11 WebSocket客户端,带指数退避重连 |
271
+
272
+ ### 业务处理层 (src/handlers/)
273
+
274
+ | 模块 | 说明 |
275
+ |------|------|
276
+ | MessageParser | 消息解析器,统一处理各种消息类型 |
277
+ | MessageHandler | 消息处理器,处理私聊/群聊消息 |
278
+ | TaskScheduler | 定时任务调度器,支持昵称检测和定时提醒 |
279
+
280
+ ### 工具模块 (src/utils/)
281
+
282
+ | 模块 | 说明 |
283
+ |------|------|
284
+ | TextProcessor | 文本处理,换行符转换、emoji编解码 |
285
+ | XMLParser | XML解析,处理引用消息、拍一拍、语音等 |
286
+
287
+ ## API接口
288
+
289
+ ### RESTful API
290
+
291
+ | 方法 | 路径 | 说明 |
292
+ |------|------|------|
293
+ | GET | /api/config | 获取配置 |
294
+ | POST | /api/config | 更新配置 |
295
+ | POST | /api/config/validate | 验证配置 |
296
+ | GET | /api/status | 获取系统状态 |
297
+ | GET | /api/status/langbot | 获取LangBot连接状态 |
298
+ | GET | /api/status/memory | 获取内存使用情况 |
299
+ | GET | /api/logs | 获取消息日志 |
300
+ | GET | /api/tasks | 获取定时任务列表 |
301
+ | POST | /api/tasks/{id}/run | 手动执行任务 |
302
+ | GET | /api/tasks/history | 获取任务执行历史 |
303
+ | POST | /api/cache/clear | 清理缓存 |
304
+ | GET | /api/chatrooms | 获取群聊列表 |
305
+ | GET | /api/friends | 获取好友列表 |
306
+ | GET | /api/group_members/{id} | 获取群成员列表 |
307
+ | GET | /api/robot_info | 获取机器人信息 |
308
+
309
+ ### WebSocket
310
+
311
+ 连接 `ws://IP:8000/api/ws` 可接收实时推送:
312
+
313
+ ```json
314
+ {"type": "log", "data": {...}} // 消息日志
315
+ {"type": "status", "data": {...}} // 状态变更
316
+ ```
317
+
318
+ ## 开发
319
+
320
+ ### 安装开发依赖
321
+
322
+ ```bash
323
+ pip install -e ".[dev]"
324
+ ```
325
+
326
+ ### 运行测试
327
+
328
+ ```bash
329
+ pytest
330
+ ```
331
+
332
+ ### 构建前端
333
+
334
+ ```bash
335
+ cd web
336
+ npm install
337
+ npm run build
338
+ ```
339
+
340
+ ## License
341
+
342
+ MIT
@@ -0,0 +1,36 @@
1
+ src/__init__.py,sha256=vpAbDzMtcITNvcXvGDWWPoKuhP57ntLtQDYme7FVlc0,1694
2
+ src/__main__.py,sha256=xuECxtjMCrz2pz6ZNRyA5FXxH3u7zw-GOXEISWgp1wg,15645
3
+ src/models.py,sha256=SooCSD2R02qx81YejqZBk5L3Jl0wl-tQ5Re9ieolj9I,2444
4
+ src/api/__init__.py,sha256=iSYGviVqNXLeGO2khEUVcEN1UDosv79Xt8awUklZDr8,473
5
+ src/api/routes.py,sha256=Vp-w0m6mhqM4AHCguQ-vasjQeZaCWQVqL5Yyvb4Nzz8,25733
6
+ src/api/websocket.py,sha256=AuhSDlqSl1Kty0iC3RbmMSrw8Q2yKYv-txC3rZCirHo,8282
7
+ src/auth/__init__.py,sha256=xTCA8viFNiJBUuIEJfPPyDRXyOXyw4v0AXf0_X1S6Z8,794
8
+ src/auth/database.py,sha256=rEjoYPi6D1gN2TxRwiFUikYq8kbUQfX3i_bH5xHLFfE,2500
9
+ src/auth/dingtalk.py,sha256=V3ydtLB_q6DHA-2DnO5V_zbVQLbmPODeo0IfW-NG0Hg,12469
10
+ src/auth/jwt_handler.py,sha256=ubKKgWlHHNPU60e-PPX4BWnIsAvGw8c9fhKujDpKr90,3394
11
+ src/auth/middleware.py,sha256=iFtTSTnmBUAlvet6cn3VomZXcpzIquWlRaJ_lWnXpW0,7501
12
+ src/auth/models.py,sha256=oMqJyN-oRuG8EISpSDrdhuZllpYuWT0EhLR3LgEZeUE,4989
13
+ src/auth/routes.py,sha256=rlFStfZuzaaZXsG1urzizIr_20CaAitRTuaC-h7R94A,12169
14
+ src/clients/__init__.py,sha256=NdzLzsRIn7ZeGw1c9DhwlJFRWcY2V0cbRcVdmPF3-SM,205
15
+ src/clients/langbot.py,sha256=qfgpZrnSC_7VKbCd7aHbEpZTw7glceY-Ue_MlIpcqvM,23869
16
+ src/clients/qianxun.py,sha256=U8W5JPNAvd06RQJIyHG5x9aql6BLC3_E8DGn_g-VsAo,16663
17
+ src/core/__init__.py,sha256=mdIksVS0TN4KYMswPK4Hu6HPAzmIndl20uGFgO6b_3A,580
18
+ src/core/config_manager.py,sha256=4qaopfp7lKPyjuGwDQV-00AzQwD2SCTPmZcYpU1y_PY,16751
19
+ src/core/log_collector.py,sha256=AZVorfzviLSdXFpOI-WJRcCxeL1rzMEPP8pu-ORoceA,5366
20
+ src/core/message_queue.py,sha256=o3xag5wheu-6cE1F2chxTvcnWlZ0HXcSvUt9YtSICo4,13567
21
+ src/core/state_store.py,sha256=r1jtM29-bEVclw4-6ZWm6hFHsue6y2YWUV3f-56-XC0,9550
22
+ src/handlers/__init__.py,sha256=FBp40REE_SWnm7seSooVJsHy4yPvB7uMOOzacxKCnHs,319
23
+ src/handlers/message_handler.py,sha256=iVbU_Ej6VL0zgoiUr2P7uZR2uKMjq_LqFa8mXkKj9OI,34371
24
+ src/handlers/message_parser.py,sha256=ls1yYeg2wdztsD7SAjcXvO34aMmxhvrXhMNPTE3i7HA,11932
25
+ src/handlers/scheduler.py,sha256=lBPnvuQ3HXeQiDaFgGyUG_3UpAUrg0ZhAQcaBc8r1KU,32555
26
+ src/static/index.html,sha256=TBiRDnFJvfOwGNmyWSku_mwq8NBCaayUUnAxaW9qBpM,476
27
+ src/static/vite.svg,sha256=SnSK_UQ5GLsWWRyDTEAdrjPoeGGrXbrQgRw6O0qSFPs,1497
28
+ src/static/assets/index-B4i68B5_.js,sha256=bWnQHWzc-k8al3zMEqOPAmbRmxaUDf3NIdk3NPVb5wI,411585
29
+ src/static/assets/index-BPXisDkw.css,sha256=7d02Hhqse51lTdwZm3v4glxiW3F_7wAavsGXdrLuKGM,29666
30
+ src/utils/__init__.py,sha256=bqOIJEwrlNDGnWA37GJUQ4gBhkiBXHAeOx-4XESKzTc,332
31
+ src/utils/text_processor.py,sha256=wJGignzN7qX9WYH0rn8JGFnNRMGumNYsD51Xjz-9JrE,5839
32
+ src/utils/xml_parser.py,sha256=rzoyqy53fsx5w81FGdWhUaQCs0ahJPkp8B_R-Qfd4Tg,7993
33
+ forcomebot-2.2.4.dist-info/METADATA,sha256=-PLUTqw6CT_GjcDWrjgo5IcFIHyuI7UDPQgiDBGwrxE,9360
34
+ forcomebot-2.2.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
35
+ forcomebot-2.2.4.dist-info/entry_points.txt,sha256=4Z2o0XIb82qLePYu7OxQ1bZtkwMmuUUY5VGuRD_IKv8,117
36
+ forcomebot-2.2.4.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ ForcomeBot = src.__main__:main
3
+ forcome-kangkang = src.__main__:main
4
+ forcomebot = src.__main__:main
src/__init__.py ADDED
@@ -0,0 +1,68 @@
1
+ """
2
+ FORCOME 康康 - 千寻微信框架Pro与LangBot中间件
3
+ 通过 OneBot v11 WebSocket 协议与 LangBot 通信
4
+
5
+ 重构后的模块结构:
6
+ - src/core/: 核心服务层(配置管理、状态存储、日志收集)
7
+ - src/clients/: 客户端层(千寻客户端、LangBot客户端)
8
+ - src/handlers/: 业务处理层(消息处理、定时任务)
9
+ - src/utils/: 工具模块(文本处理、XML解析)
10
+ - src/api/: API层(RESTful API、WebSocket)
11
+ """
12
+
13
+ __version__ = "2.0.0"
14
+
15
+ # 核心服务
16
+ from .core import (
17
+ ConfigManager,
18
+ StateStore,
19
+ LogCollector,
20
+ log_private_message,
21
+ log_group_message,
22
+ log_error,
23
+ log_system,
24
+ )
25
+
26
+ # 客户端
27
+ from .clients import QianXunClient, LangBotClient
28
+
29
+ # 业务处理
30
+ from .handlers import MessageParser, ParsedMessage, MessageHandler, TaskScheduler
31
+
32
+ # 工具模块
33
+ from .utils import TextProcessor, XMLParser, QuoteMessageResult, PatMessageResult, VoiceInfo
34
+
35
+ # 数据模型
36
+ from .models import QianXunEvent, QianXunCallback, PrivateMsgData, GroupMsgData
37
+
38
+ __all__ = [
39
+ # 版本
40
+ "__version__",
41
+ # 核心服务
42
+ "ConfigManager",
43
+ "StateStore",
44
+ "LogCollector",
45
+ "log_private_message",
46
+ "log_group_message",
47
+ "log_error",
48
+ "log_system",
49
+ # 客户端
50
+ "QianXunClient",
51
+ "LangBotClient",
52
+ # 业务处理
53
+ "MessageParser",
54
+ "ParsedMessage",
55
+ "MessageHandler",
56
+ "TaskScheduler",
57
+ # 工具模块
58
+ "TextProcessor",
59
+ "XMLParser",
60
+ "QuoteMessageResult",
61
+ "PatMessageResult",
62
+ "VoiceInfo",
63
+ # 数据模型
64
+ "QianXunEvent",
65
+ "QianXunCallback",
66
+ "PrivateMsgData",
67
+ "GroupMsgData",
68
+ ]