新增 Twitter 和 Viber 两个渠道扩展。 Twitter 渠道扩展功能模块: - auth: OAuth 认证管理 - config: 渠道配置管理 - gateway: SSE/WebSocket 网关接入 - webhook: Webhook 事件处理 - outbound: 外发消息管理 - streaming: 流式消息处理 - pairing: 用户配对与绑定 - security: 安全校验 - dedupe: 消息去重 - monitor: 渠道状态监控 - status: 会话状态管理 - session: 会话管理 - tweets: 推文管理 - social: 社交互动 - reactions: 表情反应 - media: 媒体资源处理 Viber 渠道扩展功能模块: - config: 渠道配置管理 - gateway: SSE/WebSocket 网关接入 - webhook: Webhook 事件处理 - outbound: 外发消息管理 - streaming: 流式消息处理 - pairing: 用户配对与绑定 - security: 安全校验 - dedupe: 消息去重 - monitor: 渠道状态监控 - status: 会话状态管理 - rate_limiter: 速率限制 - media: 媒体资源处理
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
from yuxi.channel.extensions.twitter.auth import probe, verify_credentials
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class TwitterStatus:
|
|
@staticmethod
|
|
async def probe_account(account: dict) -> bool:
|
|
return await probe(account)
|
|
|
|
@staticmethod
|
|
async def get_account_info(account: dict) -> dict | None:
|
|
return await verify_credentials(account)
|
|
|
|
@staticmethod
|
|
def build_summary(account: dict, user_info: dict | None = None) -> dict:
|
|
summary: dict = {
|
|
"account_id": account.get("account_id", ""),
|
|
"configured": all(
|
|
[
|
|
account.get("api_key"),
|
|
account.get("api_secret"),
|
|
account.get("access_token"),
|
|
account.get("access_secret"),
|
|
]
|
|
),
|
|
"dm_policy": account.get("dm_policy", "pairing"),
|
|
"group_policy": account.get("group_policy", "disabled"),
|
|
"connection_mode": account.get("connection_mode", "auto"),
|
|
}
|
|
if user_info:
|
|
summary["user_id"] = user_info.get("user_id", "")
|
|
summary["username"] = user_info.get("username", "")
|
|
summary["display_name"] = user_info.get("name", "")
|
|
summary["online"] = True
|
|
return summary
|