mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-05 05:16:03 +00:00
feat: add wecomcs
This commit is contained in:
@@ -1,15 +1,3 @@
|
||||
"""统一 Webhook 路由组
|
||||
|
||||
处理所有外部平台的回调请求,统一在一个端口上通过 bot_uuid 路由到对应的适配器。
|
||||
|
||||
路由格式:
|
||||
- /bots/{bot_uuid} - 处理 bot 的 webhook 回调
|
||||
- /bots/{bot_uuid}/{path} - 处理带子路径的 webhook 回调
|
||||
|
||||
Example:
|
||||
http://your-server.com:5300/bots/550e8400-e29b-41d4-a716-446655440000
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import quart
|
||||
@@ -42,7 +30,7 @@ class WebhookRouterGroup(group.RouterGroup):
|
||||
适配器返回的响应
|
||||
"""
|
||||
try:
|
||||
# 通过 UUID 获取运行时 bot
|
||||
|
||||
runtime_bot = await self.ap.platform_mgr.get_bot_by_uuid(bot_uuid)
|
||||
|
||||
if not runtime_bot:
|
||||
@@ -51,11 +39,11 @@ class WebhookRouterGroup(group.RouterGroup):
|
||||
if not runtime_bot.enable:
|
||||
return quart.jsonify({'error': 'Bot is disabled'}), 403
|
||||
|
||||
# 检查 adapter 是否支持统一 webhook
|
||||
|
||||
if not hasattr(runtime_bot.adapter, 'handle_unified_webhook'):
|
||||
return quart.jsonify({'error': 'Adapter does not support unified webhook'}), 501
|
||||
|
||||
# 调用 adapter 的 handle_unified_webhook 方法,显式传递 request 对象
|
||||
|
||||
response = await runtime_bot.adapter.handle_unified_webhook(
|
||||
bot_uuid=bot_uuid,
|
||||
path=path,
|
||||
|
||||
Reference in New Issue
Block a user