API

WeCom access token management, message sending, and Markdown stripping.

Markdown 清理

WeCom 客户端不渲染 Markdown,发送前需将 AI 回复中的代码块、加粗、标题、列表、链接等语法替换为纯文本或简单符号。

Access Token 管理

WeCom Access Token 有效期约2小时,通过模块级缓存 _token_cache 避免频繁请求。get_access_token 在到期前 TOKEN_BUFFER 秒自动刷新。

消息发送

WeCom 单条消息有字符限制,send_textCHUNK_SIZE 自动分段发送,并在每段失败时记录日志而不中断后续分段。


source

send_text


async def send_text(
    user_id:str, # WeCom recipient user ID
    text:str, # Message text; Markdown is stripped automatically
):

Send text via the WeCom API, chunking into CHUNK_SIZE-char segments.