3 个版本 (破坏性更新)
| 0.3.0 | 2022年1月23日 |
|---|---|
| 0.2.0 | 2021年11月8日 |
| 0.1.0 | 2021年11月8日 |
#28 in #cloudflare-workers
380KB
7K SLoC
telbot
Telbot 提供了 Telegram 机器人类型和 API 封装器。
具体来说,telbot 现在支持
- telbot-types: 基本的 Telegram 类型 / 请求 / 响应
[dependencies]
telbot-types = "0.3.0"
- telbot-cf-worker: Cloudflare Workers 的 API 封装器
[dependencies]
telbot-cf-worker = "0.3.0"
- telbot-ureq: ureq 客户端的 API 封装器
[dependencies]
telbot-ureq = "0.3.0"
- telbot-hyper: hyper 客户端的 API 封装器
[dependencies]
telbot-hyper = "0.1.0"
示例
扩展 telbot
您可以通过实现两个方法,send_json 和 send_file,使用您自己的 HTTP 客户端来创建自己的 API 封装器。
send_json 应将 JsonMethod 序列化为 JSON 格式并发送到 API 端点。
send_file 应将 FileMethod 序列化为 multipart/form-data 格式并发送到 API 端点。
files(&self) 方法在 FileMethod 中有助于获取类型为 InputFileVariant 的字段。
为了便于序列化,JsonMethod 和 FileMethod 都实现了 serde::Serialize。
TelegramMethod,是 JsonMethod 和 FileMethod 的超特性,提供了 name() 方法,可用于以 &str 格式获取方法名称。
贡献
telbot 仍不是一个成熟的项目,所以您的帮助将非常有用。
如果您发现错误编码的部分或对改进 telbot 有好主意,请留下问题。
依赖项
~13–25MB
~416K SLoC