Expand description
§WeChat iLink Bot — Rust SDK
基于微信官方 iLink Bot HTTP/JSON 协议 的完整异步客户端。
支持扫码登录、长轮询收消息、发送文本/图片/文件/语音、AES-128-ECB 媒体加解密。
§快速开始
use aibot::{BotResult, ILinkClient};
#[tokio::main]
async fn main() -> BotResult<()> {
// 已有 Token 直接连接
let client = ILinkClient::new("your_bot_token", None);
// 长轮询接收消息
let updates = client.get_updates("").await?;
for msg in updates.msgs {
println!("收到消息 from: {}", msg.from_user_id);
}
Ok(())
}§完整示例(含扫码登录)
见 main.rs ——
一个可运行的 Bot 封装,支持 Token 持久化、自动扫码、消息循环。
Re-exports§
pub use client::ILinkClient;pub use error::BotError;pub use error::BotResult;pub use self;pub use self;pub use types::*;
Modules§
- client
- HTTP API 客户端 —— 封装所有 iLink 端点调用。
- crypto
- AES-128-ECB 加解密工具 —— 用于媒体文件加解密。
- error
- 错误类型体系 —— 结构化
BotError枚举,替代anyhow。 - types
- 协议类型定义 —— 所有请求/响应结构体、枚举。
Macros§
- json
- Construct a
serde_json::Valuefrom a JSON literal.
Structs§
- Json
Error - This type represents all possible errors that can occur when serializing or deserializing JSON data.
- JsonMap
- Represents a JSON key/value type.
Enums§
- Json
Value - Represents any valid JSON value.
Traits§
- Deserialize
- A data structure that can be deserialized from any data format supported by Serde.
- Deserialize
Owned - A data structure that can be deserialized without borrowing any data from the deserializer.
- Serialize
- A data structure that can be serialized into any data format supported by Serde.
Functions§
- from_
reader - Deserialize an instance of type
Tfrom an I/O stream of JSON. - from_
slice - Deserialize an instance of type
Tfrom bytes of JSON text. - from_
str - Deserialize an instance of type
Tfrom a string of JSON text. - from_
value - Interpret a
serde_json::Valueas an instance of typeT. - to_
string - Serialize the given data structure as a String of JSON.
- to_
string_ pretty - Serialize the given data structure as a pretty-printed String of JSON.
- to_
value - Convert a
Tintoserde_json::Valuewhich is an enum that can represent any valid JSON data. - to_vec
- Serialize the given data structure as a JSON byte vector.
- to_
vec_ pretty - Serialize the given data structure as a pretty-printed JSON byte vector.
- to_
writer - Serialize the given data structure as JSON into the I/O stream.
- to_
writer_ pretty - Serialize the given data structure as pretty-printed JSON into the I/O stream.
Type Aliases§
- Json
Result - Alias for a
Resultwith the error typeserde_json::Error.
Derive Macros§
- Deserialize
- Derive macro available if serde is built with
features = ["derive"]. - Serialize
- Derive macro available if serde is built with
features = ["derive"].