实现了完整的Flock渠道接入能力,包含消息收发、Webhook事件监听、账号配置、安全校验、媒体文件处理等功能,支持私聊和群组聊天,适配ForcePilot插件规范。
32 lines
874 B
Python
32 lines
874 B
Python
from __future__ import annotations
|
|
|
|
from yuxi.channel.protocols import ReplyTransport
|
|
|
|
|
|
def extract_thread_id(msg) -> str | None:
|
|
if hasattr(msg, "message_thread_id"):
|
|
return msg.message_thread_id
|
|
if hasattr(msg, "raw_payload"):
|
|
raw = msg.raw_payload
|
|
if isinstance(raw, dict):
|
|
event = raw.get("event", {})
|
|
if isinstance(event, dict):
|
|
message = event.get("message", {})
|
|
if isinstance(message, dict):
|
|
return message.get("threadId")
|
|
return None
|
|
|
|
|
|
def resolve_reply_transport(msg, thread_id: str | None) -> ReplyTransport:
|
|
return ReplyTransport(mode="inline", thread_id=thread_id)
|
|
|
|
|
|
def resolve_auto_thread_id(
|
|
config: dict,
|
|
account_id: str,
|
|
to: str,
|
|
tool_context=None,
|
|
reply_to_id: str | None = None,
|
|
) -> str | None:
|
|
return reply_to_id
|