新增 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: 媒体资源处理
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
from enum import IntEnum
|
|
|
|
|
|
class ViberErrorCode(IntEnum):
|
|
OK = 0
|
|
INVALID_URL = 1
|
|
INVALID_AUTH_TOKEN = 2
|
|
BAD_DATA = 3
|
|
MISSING_DATA = 4
|
|
RECEIVER_NOT_REGISTERED = 5
|
|
RECEIVER_NOT_SUBSCRIBED = 6
|
|
PUBLIC_ACCOUNT_BLOCKED = 7
|
|
PUBLIC_ACCOUNT_NOT_FOUND = 8
|
|
PUBLIC_ACCOUNT_SUSPENDED = 9
|
|
WEBHOOK_NOT_SET = 10
|
|
RECEIVER_NO_SUITABLE_DEVICE = 11
|
|
TOO_MANY_REQUESTS = 12
|
|
API_VERSION_NOT_SUPPORTED = 13
|
|
INCOMPATIBLE_WITH_VERSION = 14
|
|
PUBLIC_ACCOUNT_NOT_AUTHORIZED = 15
|
|
INCHAT_REPLY_MESSAGE_NOT_ALLOWED = 16
|
|
PUBLIC_ACCOUNT_IS_NOT_INLINE = 17
|
|
NO_PUBLIC_CHAT = 18
|
|
CANNOT_SEND_BROADCAST = 19
|
|
BROADCAST_NOT_ALLOWED = 20
|
|
RATE_LIMIT_EXCEEDED = 49
|
|
GENERAL = 50
|
|
|
|
@classmethod
|
|
def is_retryable(cls, code: int) -> bool:
|
|
return code in (
|
|
cls.TOO_MANY_REQUESTS,
|
|
cls.RATE_LIMIT_EXCEEDED,
|
|
cls.GENERAL,
|
|
)
|
|
|
|
@classmethod
|
|
def is_auth_error(cls, code: int) -> bool:
|
|
return code in (
|
|
cls.INVALID_AUTH_TOKEN,
|
|
cls.PUBLIC_ACCOUNT_NOT_AUTHORIZED,
|
|
)
|