1. 调整多个文件的导入顺序与格式,统一代码风格 2. 在security模块新增允许列表持久化存储逻辑 3. 新增send_sticker/send_voice/send_silent/pin/unpin等消息操作 4. 新增群组创建/删除/成员管理方法 5. 重构流式消息处理逻辑,提取为独立工具类 6. 修复配置校验与安全检查的逻辑顺序问题 7. 优化初始化流程,新增配置校验步骤
47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
|
|
from yuxi.channels.adapters.signal.normalize import normalize_target
|
|
from yuxi.channels.models import ChatType
|
|
|
|
|
|
@dataclass
|
|
class OutboundSession:
|
|
peer: str
|
|
chat_type: ChatType
|
|
from_: str
|
|
to: str
|
|
|
|
@classmethod
|
|
def resolve(cls, target: str, account_number: str) -> OutboundSession:
|
|
normalized = normalize_target(target)
|
|
if normalized.startswith("group:"):
|
|
return cls(
|
|
peer=normalized,
|
|
chat_type=ChatType.GROUP,
|
|
from_=account_number,
|
|
to=normalized,
|
|
)
|
|
if normalized.startswith("uuid:"):
|
|
return cls(
|
|
peer=normalized,
|
|
chat_type=ChatType.DIRECT,
|
|
from_=account_number,
|
|
to=normalized,
|
|
)
|
|
return cls(
|
|
peer=normalized,
|
|
chat_type=ChatType.DIRECT,
|
|
from_=account_number,
|
|
to=normalized,
|
|
)
|
|
|
|
@property
|
|
def is_group(self) -> bool:
|
|
return self.chat_type == ChatType.GROUP
|
|
|
|
@property
|
|
def conversation_id(self) -> str:
|
|
return self.peer
|