Skip to main content

Crate aibot

Crate aibot 

Source
Expand description

基于微信官方 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::Value from a JSON literal.

Structs§

JsonError
This type represents all possible errors that can occur when serializing or deserializing JSON data.
JsonMap
Represents a JSON key/value type.

Enums§

JsonValue
Represents any valid JSON value.

Traits§

Deserialize
A data structure that can be deserialized from any data format supported by Serde.
DeserializeOwned
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 T from an I/O stream of JSON.
from_slice
Deserialize an instance of type T from bytes of JSON text.
from_str
Deserialize an instance of type T from a string of JSON text.
from_value
Interpret a serde_json::Value as an instance of type T.
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 T into serde_json::Value which 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§

JsonResult
Alias for a Result with the error type serde_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"].