新增腾讯 IM(Tencent IM)渠道扩展,支持在 Yuxi 平台中集成腾讯即时通讯 IM 渠道。 包含以下功能模块: - config: 渠道配置管理 - gateway: SSE/WebSocket 网关接入 - webhook: Webhook 事件处理 - outbound: 外发消息管理 - pairing: 用户配对与绑定 - security: 安全校验 - signature: 请求签名验证 - usersig: UserSig 生成 - dedupe: 消息去重 - status: 会话状态管理 - group: 群组管理 - types: 类型定义
31 lines
973 B
Python
31 lines
973 B
Python
import logging
|
|
|
|
from yuxi.channel.extensions.tencent_im.gateway import TencentIMError, TencentIMGateway
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class TencentIMStatus:
|
|
def __init__(self, gateway: TencentIMGateway | None = None):
|
|
self._gateway = gateway
|
|
|
|
async def probe(self, account: dict | None = None) -> bool:
|
|
if not self._gateway or not self._gateway._running:
|
|
return False
|
|
try:
|
|
await self._gateway.call_api(
|
|
"im_open_login_svc/account_check", {"CheckItem": [{"UserID": self._gateway.account.admin_userid}]}
|
|
)
|
|
return True
|
|
except (TencentIMError, Exception):
|
|
logger.warning("TencentIM status probe failed")
|
|
return False
|
|
|
|
def build_summary(self, snapshot: object) -> dict:
|
|
return {
|
|
"channel": "tencent-im",
|
|
"mode": "webhook",
|
|
"output_format": "json",
|
|
"streaming": "block",
|
|
}
|