新增 KakaoTalk 渠道扩展,支持在 Yuxi 平台中集成 KakaoTalk 即时通讯渠道。 包含以下功能模块: - bot: Bot 客户端封装 - config: 渠道配置管理 - gateway: SSE/WebSocket 网关接入 - webhook: Webhook 事件处理 - outbound: 外发消息管理 - streaming: 流式消息处理 - pairing: 用户配对与绑定 - security: 安全校验 - dedupe: 消息去重 - monitor: 渠道状态监控 - status: 会话状态管理 - card_builder: KakaoTalk 卡片消息构建 - quick_reply: 快捷回复处理 - types: 类型定义
30 lines
816 B
Python
30 lines
816 B
Python
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
async def check_admin_key_valid(admin_key: str) -> bool:
|
|
from yuxi.channel.extensions.kakaotalk.bot import KakaoTalkBotClient
|
|
|
|
try:
|
|
client = KakaoTalkBotClient(admin_key=admin_key)
|
|
return await client.probe()
|
|
except Exception:
|
|
return False
|
|
|
|
|
|
async def check_skill_server_connectivity(skill_server_url: str) -> bool:
|
|
import httpx
|
|
|
|
try:
|
|
async with httpx.AsyncClient(timeout=httpx.Timeout(5.0)) as client:
|
|
resp = await client.post(
|
|
skill_server_url,
|
|
json={"dummy": True},
|
|
headers={"Content-Type": "application/json"},
|
|
)
|
|
return resp.status_code < 500
|
|
except Exception:
|
|
return False |