1. 调整多个文件的导入顺序与格式,统一代码风格 2. 在security模块新增允许列表持久化存储逻辑 3. 新增send_sticker/send_voice/send_silent/pin/unpin等消息操作 4. 新增群组创建/删除/成员管理方法 5. 重构流式消息处理逻辑,提取为独立工具类 6. 修复配置校验与安全检查的逻辑顺序问题 7. 优化初始化流程,新增配置校验步骤
18 lines
645 B
Python
18 lines
645 B
Python
from yuxi.channels.adapters.signal.normalize import normalize_e164
|
|
from yuxi.channels.models import ChannelIdentity, ChannelType
|
|
|
|
|
|
def resolve_thread(identity: ChannelIdentity, agent_id: str = "main") -> str:
|
|
chat_id = identity.channel_chat_id
|
|
channel_type = identity.channel_type
|
|
|
|
if channel_type != ChannelType.SIGNAL:
|
|
raise ValueError(f"Unexpected channel type: {channel_type}")
|
|
|
|
if chat_id.startswith("group:"):
|
|
group_id = chat_id.removeprefix("group:")
|
|
return f"agent:{agent_id}:signal:group:{group_id}"
|
|
|
|
normalized = normalize_e164(chat_id)
|
|
return f"agent:{agent_id}:signal:dm:{normalized}"
|