用途:通过 uxc + OpenAPI 执行 Telegram Bot API 操作,复用 uxc 在鉴权、执行与错误处理上的通用能力。
主要能力:覆盖精简的机器人核心操作,包括机器人身份与聊天查询、文本发送、按 file_id、HTTP URL 或本地 multipart 上传发送媒体、getUpdates 轮询、webhook 的设置/状态/删除。不覆盖含 attach:// 文件数组的媒体组、通用 webhook 接收运行时托管以及完整 Bot API。
使用方式:需已安装 uxc 并位于 PATH,可访问 https://api.telegram.org 与定制 schema,并持有 BotFather 的 bot token。鉴权走请求路径前缀模板:uxc auth credential set telegram-bot --auth-type api_key --secret-env TELEGRAM_BOT_TOKEN --path-prefix-template "/bot{{secret}}",再执行 uxc auth binding add --id telegram-bot --host api.telegram.org --scheme https --credential telegram-bot --priority 100。可用 uxc auth binding match https://api.telegram.org/getMe 校验映射。默认使用固定链接命令 telegram-openapi-cli;若缺失则用 uxc link telegram-openapi-cli https://api.telegram.org --schema-url <schema 地址> 创建。先看帮助与 schema,如 telegram-openapi-cli get:/getMe -h、post:/sendMessage -h 等。执行示例:telegram-openapi-cli post:/sendMessage chat_id=CHAT_ID text="Hello from uxc";multipart 上传:telegram-openapi-cli post:/sendPhoto chat_id=CHAT_ID photo=/tmp/photo.jpg caption="Uploaded by uxc";也支持位置 JSON 参数。轮询订阅可用 uxc subscribe start https://api.telegram.org post:/getUpdates 配合 --mode poll 与 poll-config。
限制与防护:自动化应保持 JSON 输出外壳,不要用 --text,优先解析 ok、kind、protocol、data、error。getUpdates 与 webhook 互斥,若已设 webhook 需先调用 post:/deleteWebhook;每个 bot token 只允许一个活跃 getUpdates 消费者,否则返回 HTTP 409。轮询订阅建议用基于条目的 offset 推进(extract_items_pointer 为 /result、request_cursor_arg 为 offset、cursor_from_item_pointer 为 /update_id、cursor_transform 为 increment,checkpoint_strategy 通常用 item_key 且 item_key_pointer 为 /update_id)。sendPhoto、sendDocument 在本技能中接受已有 file_id 或 HTTP URL,且支持 multipart 本地文件上传,但文件字段须为本地路径字符串;sendMediaGroup 仍仅限 JSON,setWebhook 支持通过 certificate 字段上传自签名证书。sendMessage 等发送操作与 webhook 变更属写入/高风险动作,执行前须经用户明确确认。参考资料含 usage-patterns.md、定制 schema 与 Telegram Bot API 文档等。