新增了完整的Signal渠道适配器实现,包含RPC客户端、守护进程管理、安全策略、消息处理、安装配置工具等全套功能,支持通过signal-cli与Signal网络进行通信,包含账户管理、消息收发、反应处理、媒体分析、健康检查等能力。
47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
|
|
from yuxi.channels.models import ChatType
|
|
from yuxi.channels.adapters.signal.normalize import normalize_target
|
|
|
|
|
|
@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
|