Files
company-ai-platform/logs/feishu_long_connection.err.log
JiuContinent 09933b15ad ```
feat(feishu): 添加飞书长连接支持并重构事件处理

添加了 FeishuEventService 来统一处理飞书消息事件,
新增 long_connection.py 实现长连接客户端,
修改 webhook 路由使用新的事件处理服务,
添加了 lark-oapi 依赖支持长连接功能,
更新测试用例覆盖新的事件处理逻辑。

BREAKING CHANGE: 飞书事件处理逻辑重构,统一使用
FeishuEventService 进行消息处理和审计记录。
```
2026-06-22 14:54:20 +08:00

15 lines
4.9 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

INFO:__main__:Starting Feishu long connection client
INFO:httpx:HTTP Request: POST https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal "HTTP/1.1 200 OK"
INFO:httpx:HTTP Request: POST https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=chat_id "HTTP/1.1 200 OK"
INFO:__main__:Handled Feishu long connection event: {'ok': True, 'handled': True, 'result': {'command': 'risk_summary', 'reply_type': 'card', 'title': '风险预警', 'content': '- 综合风险等级low\n- 风险分0\n- 逾期任务0\n- 延期项目0\n- 超预算项目0\n- 资金风险账户0', 'lines': ['- 综合风险等级low', '- 风险分0', '- 逾期任务0', '- 延期项目0', '- 超预算项目0', '- 资金风险账户0'], 'provider_response': {'code': 0, 'data': {'body': {'content': '{"title":"风险预警","elements":[[{"tag":"text","text":"- 综合风险等级low\\n- 风险分0\\n- 逾期任务0\\n- 延期项目0\\n- 超预算项目0\\n- 资金风险账户0"}]]}'}, 'chat_id': 'oc_4ea0ed9fbfe4da2aca67cca9ee22cb36', 'create_time': '1782103535265', 'deleted': False, 'message_id': 'om_x100b6cbf902318acb15878ba4b86f90', 'msg_type': 'interactive', 'sender': {'id': 'cli_aab22b1674799bef', 'id_type': 'app_id', 'sender_type': 'app', 'tenant_key': '1b3485e1c8ea174f'}, 'update_time': '1782103535265', 'updated': False}, 'msg': 'success'}}}
INFO:httpx:HTTP Request: POST https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal "HTTP/1.1 200 OK"
INFO:httpx:HTTP Request: POST https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=chat_id "HTTP/1.1 200 OK"
INFO:__main__:Handled Feishu long connection event: {'ok': True, 'handled': True, 'result': {'command': 'risk_summary', 'reply_type': 'card', 'title': '风险预警', 'content': '- 综合风险等级low\n- 风险分0\n- 逾期任务0\n- 延期项目0\n- 超预算项目0\n- 资金风险账户0', 'lines': ['- 综合风险等级low', '- 风险分0', '- 逾期任务0', '- 延期项目0', '- 超预算项目0', '- 资金风险账户0'], 'provider_response': {'code': 0, 'data': {'body': {'content': '{"title":"风险预警","elements":[[{"tag":"text","text":"- 综合风险等级low\\n- 风险分0\\n- 逾期任务0\\n- 延期项目0\\n- 超预算项目0\\n- 资金风险账户0"}]]}'}, 'chat_id': 'oc_4ea0ed9fbfe4da2aca67cca9ee22cb36', 'create_time': '1782103549102', 'deleted': False, 'message_id': 'om_x100b6cbf91060cacb1fa837ac0932ee', 'msg_type': 'interactive', 'sender': {'id': 'cli_aab22b1674799bef', 'id_type': 'app_id', 'sender_type': 'app', 'tenant_key': '1b3485e1c8ea174f'}, 'update_time': '1782103549102', 'updated': False}, 'msg': 'success'}}}
INFO:httpx:HTTP Request: POST https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal "HTTP/1.1 200 OK"
INFO:httpx:HTTP Request: POST https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=chat_id "HTTP/1.1 200 OK"
INFO:__main__:Handled Feishu long connection event: {'ok': True, 'handled': True, 'result': {'command': 'fallback_ai', 'reply_type': 'text', 'title': 'AI 回复', 'content': 'AI provider is not configured yet. This is a deterministic placeholder. Set MODEL_PROVIDER to openclaw, hermes, or direct_llm after credentials are ready.', 'provider_response': {'code': 0, 'data': {'body': {'content': '{"text":"AI provider is not configured yet. This is a deterministic placeholder. Set MODEL_PROVIDER to openclaw, hermes, or direct_llm after credentials are ready."}'}, 'chat_id': 'oc_4ea0ed9fbfe4da2aca67cca9ee22cb36', 'create_time': '1782103556285', 'deleted': False, 'message_id': 'om_x100b6cbfae8fc8acb03feca923be229', 'msg_type': 'text', 'sender': {'id': 'cli_aab22b1674799bef', 'id_type': 'app_id', 'sender_type': 'app', 'tenant_key': '1b3485e1c8ea174f'}, 'update_time': '1782103556285', 'updated': False}, 'msg': 'success'}}}
INFO:httpx:HTTP Request: POST https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal "HTTP/1.1 200 OK"
INFO:httpx:HTTP Request: POST https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=chat_id "HTTP/1.1 200 OK"
INFO:__main__:Handled Feishu long connection event: {'ok': True, 'handled': True, 'result': {'command': 'risk_summary', 'reply_type': 'card', 'title': '风险预警', 'content': '- 综合风险等级low\n- 风险分0\n- 逾期任务0\n- 延期项目0\n- 超预算项目0\n- 资金风险账户0', 'lines': ['- 综合风险等级low', '- 风险分0', '- 逾期任务0', '- 延期项目0', '- 超预算项目0', '- 资金风险账户0'], 'provider_response': {'code': 0, 'data': {'body': {'content': '{"title":"风险预警","elements":[[{"tag":"text","text":"- 综合风险等级low\\n- 风险分0\\n- 逾期任务0\\n- 延期项目0\\n- 超预算项目0\\n- 资金风险账户0"}]]}'}, 'chat_id': 'oc_4ea0ed9fbfe4da2aca67cca9ee22cb36', 'create_time': '1782105193432', 'deleted': False, 'message_id': 'om_x100b6cb8085c94a4b12d99465abb1ca', 'msg_type': 'interactive', 'sender': {'id': 'cli_aab22b1674799bef', 'id_type': 'app_id', 'sender_type': 'app', 'tenant_key': '1b3485e1c8ea174f'}, 'update_time': '1782105193432', 'updated': False}, 'msg': 'success'}}}
ERROR:Lark:receive message loop exit, err: no close frame received or sent [conn_id=7654075862284225524]