新增 Facebook Messenger 渠道扩展,支持在 Yuxi 平台中集成 Messenger 即时通讯渠道。 包含以下功能模块: - config: 渠道配置管理 - gateway: SSE/WebSocket 网关接入 - webhook: Webhook 事件处理 - outbound: 外发消息管理 - streaming: 流式消息处理 - pairing: 用户配对与绑定 - security: 安全校验 - dedupe: 消息去重 - monitor: 渠道状态监控 - status: 会话状态管理 - actions: 动作处理 - template: 消息模板 - quick_reply: 快捷回复 - private_reply: 私密回复 - handover: 转人工切换 - persona: 人设管理 - profile: 主页配置 - user: 用户信息 - insights: 数据洞察 - notification: 通知推送 - media: 媒体资源处理 - types: 类型定义
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
from enum import Enum
|
|
|
|
|
|
class MessengerErrorKind(Enum):
|
|
UNKNOWN = "unknown"
|
|
TOKEN_EXPIRED = "token_expired"
|
|
WINDOW_EXPIRED = "window_expired"
|
|
USER_BLOCKED = "user_blocked"
|
|
RATE_LIMITED = "rate_limited"
|
|
PERMISSION_DENIED = "permission_denied"
|
|
INVALID_PARAMETER = "invalid_parameter"
|
|
SERVICE_ERROR = "service_error"
|
|
MESSAGE_TAG_INVALID = "message_tag_invalid"
|
|
|
|
|
|
def classify_error(error_code: int, error_subcode: int = 0) -> MessengerErrorKind:
|
|
if error_code == 190:
|
|
return MessengerErrorKind.TOKEN_EXPIRED
|
|
if error_code == 10:
|
|
if error_subcode in (2018028, 2018108):
|
|
return MessengerErrorKind.WINDOW_EXPIRED
|
|
if error_subcode == 2018065:
|
|
return MessengerErrorKind.MESSAGE_TAG_INVALID
|
|
if error_code == 551 and error_subcode == 1545041:
|
|
return MessengerErrorKind.USER_BLOCKED
|
|
if error_code in (4, 613, 368):
|
|
return MessengerErrorKind.RATE_LIMITED
|
|
if error_code == 200:
|
|
return MessengerErrorKind.PERMISSION_DENIED
|
|
if error_code == 100:
|
|
return MessengerErrorKind.INVALID_PARAMETER
|
|
if error_code in (1, 2):
|
|
return MessengerErrorKind.SERVICE_ERROR
|
|
return MessengerErrorKind.UNKNOWN
|