"""
飞书平台常量定义
"""

# 消息类型
MSG_TYPE_TEXT = "text"
MSG_TYPE_POST = "post"  # 富文本
MSG_TYPE_INTERACTIVE = "interactive"  # 卡片消息
MSG_TYPE_IMAGE = "image"
MSG_TYPE_SHARE_CHAT = "share_chat"  # 群名片

# 分段设置
MAX_BYTES_PER_MESSAGE = 19000  # 实际限制 20KB，留安全余量

# 频率限制
RATE_LIMIT_PER_MINUTE = 100  # 每分钟 100 条
RATE_LIMIT_PER_SECOND = 5    # 每秒 5 条

# 重试设置
DEFAULT_MAX_RETRIES = 3
DEFAULT_RETRY_DELAY = 2.0
DEFAULT_BACKOFF_FACTOR = 2.0

# HTTP 设置
DEFAULT_TIMEOUT = 10

# 服务端频控重试
RATE_LIMIT_MAX_RETRIES = 5
RATE_LIMIT_WAIT_TIME = 65

# 错误码
CODE_SUCCESS = 0
CODE_BAD_REQUEST = 9499
CODE_RATE_LIMIT = 11232  # 限流错误
CODE_KEYWORD_FAILED = 19024  # 关键词校验失败
CODE_IP_FAILED = 19022  # IP 白名单校验失败
CODE_SIGN_FAILED = 19021  # 签名校验失败

# Webhook URL 格式
WEBHOOK_URL_PATTERN = r"https://open\.feishu\.cn/open-apis/bot/v2/hook/[\w-]+"

# 卡片模板颜色
CARD_TEMPLATE_BLUE = "blue"
CARD_TEMPLATE_WATHET = "wathet"
CARD_TEMPLATE_TURQUOISE = "turquoise"
CARD_TEMPLATE_GREEN = "green"
CARD_TEMPLATE_YELLOW = "yellow"
CARD_TEMPLATE_ORANGE = "orange"
CARD_TEMPLATE_RED = "red"
CARD_TEMPLATE_CARMINE = "carmine"
CARD_TEMPLATE_VIOLET = "violet"
CARD_TEMPLATE_PURPLE = "purple"
CARD_TEMPLATE_INDIGO = "indigo"
CARD_TEMPLATE_GREY = "grey"

DEFAULT_CARD_TEMPLATE = CARD_TEMPLATE_BLUE

__all__ = [
    # 消息类型
    "MSG_TYPE_TEXT",
    "MSG_TYPE_POST",
    "MSG_TYPE_INTERACTIVE",
    "MSG_TYPE_IMAGE",
    "MSG_TYPE_SHARE_CHAT",
    # 分段设置
    "MAX_BYTES_PER_MESSAGE",
    # 频率限制
    "RATE_LIMIT_PER_MINUTE",
    "RATE_LIMIT_PER_SECOND",
    # 重试设置
    "DEFAULT_MAX_RETRIES",
    "DEFAULT_RETRY_DELAY",
    "DEFAULT_BACKOFF_FACTOR",
    # HTTP 设置
    "DEFAULT_TIMEOUT",
    # 服务端频控
    "RATE_LIMIT_MAX_RETRIES",
    "RATE_LIMIT_WAIT_TIME",
    # 错误码
    "CODE_SUCCESS",
    "CODE_BAD_REQUEST",
    "CODE_RATE_LIMIT",
    "CODE_KEYWORD_FAILED",
    "CODE_IP_FAILED",
    "CODE_SIGN_FAILED",
    # URL 格式
    "WEBHOOK_URL_PATTERN",
    # 卡片模板
    "CARD_TEMPLATE_BLUE",
    "CARD_TEMPLATE_WATHET",
    "CARD_TEMPLATE_TURQUOISE",
    "CARD_TEMPLATE_GREEN",
    "CARD_TEMPLATE_YELLOW",
    "CARD_TEMPLATE_ORANGE",
    "CARD_TEMPLATE_RED",
    "CARD_TEMPLATE_CARMINE",
    "CARD_TEMPLATE_VIOLET",
    "CARD_TEMPLATE_PURPLE",
    "CARD_TEMPLATE_INDIGO",
    "CARD_TEMPLATE_GREY",
    "DEFAULT_CARD_TEMPLATE",
]
