示例
仓库示例位于 crates/jingzhe/examples。
| 示例 | 内容 |
|---|---|
get_me |
查询机器人信息,了解最小 API 请求 |
polling |
命令、共享状态、消息处理与类型化按钮回调 |
files |
上传、下载与复用 Telegram 文件 |
full_api |
类型化事件宏、富消息、Widgets 与 Inline Mode |
webhook |
独立运行 Axum Webhook 服务 |
axum_integration |
将 Webhook 路由接入已有 Axum 服务 |
普通示例:
cargo run -p jingzhe --example get_mecargo run -p jingzhe --example pollingcargo run -p jingzhe --example filescargo run -p jingzhe --example full_apiWebhook 示例需要启用 feature:
cargo run -p jingzhe --features webhook --example webhookcargo run -p jingzhe --features webhook --example axum_integration在仓库根目录复制配置模板:
cp -n .env.example .env至少填写:
TELEGRAM_BOT_TOKEN=替换为你的BotToken文件示例还需要 TELEGRAM_CHAT_ID 和 UPLOAD_PATH。Webhook 示例还需要 WEBHOOK_URL 和 WEBHOOK_SECRET。