新增小红书、XMPP、元宝、Zalo 四个渠道扩展。 小红书渠道扩展主要模块:config, gateway, webhook, outbound, streaming, pairing, security, dedupe, media, status, window XMPP 渠道扩展主要模块:plugin, config, gateway, outbound, streaming, pairing, security, dedupe, accounts, commands, muc, rate_limiter, stanza_utils, status, monitor 元宝渠道扩展主要模块:plugin, client, config_schema, gateway, outbound(chunk/queue/transport), inbound(dispatcher), streaming, pairing, security, accounts, actions, commands, codec(biz/conn), session, shared, utils Zalo 渠道扩展主要模块:api, config, gateway, webhook, outbound, pairing, security, session, polling, monitor, status
22 lines
656 B
Python
22 lines
656 B
Python
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
from yuxi.channel.extensions.yuanbao.types import YuanbaoChatType
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def build_session_key(account_id: str, chat_type: YuanbaoChatType, peer_id: str) -> str:
|
|
if chat_type == YuanbaoChatType.C2C:
|
|
return f"{account_id}:c2c:{peer_id}"
|
|
return f"{account_id}:group:{peer_id}"
|
|
|
|
|
|
def c2c_session_key(account_id: str, open_id: str) -> str:
|
|
return build_session_key(account_id, YuanbaoChatType.C2C, open_id)
|
|
|
|
|
|
def group_session_key(account_id: str, group_open_id: str) -> str:
|
|
return build_session_key(account_id, YuanbaoChatType.GROUP, group_open_id)
|