wechatbot — Rust SDK
WeChat iLink Bot SDK for Rust — async, type-safe, zero-copy where possible.
Install
[]
= "0.1"
= { = "1", = ["full"] }
Requires Rust 2021 edition. Built on tokio + reqwest.
Quick Start
use ;
async
Architecture
src/
├── lib.rs ← Public re-exports
├── types.rs ← All protocol & public types (serde)
├── error.rs ← Error hierarchy (thiserror)
├── protocol.rs ← Raw iLink API calls (reqwest)
├── crypto.rs ← AES-128-ECB encrypt/decrypt + key encoding
└── bot.rs ← WeChatBot client (login, run, reply, send)
API Reference
Creating a Bot
use ;
let bot = new;
Authentication
// Login (skips QR if credentials exist)
let creds = bot.login.await?;
// Force re-login
let creds = bot.login.await?;
// Credentials struct
println!;
println!;
println!;
println!;
Message Handling
bot.on_message.await;
Sending Messages
// Reply to incoming message
bot.reply.await?;
// Send to user (needs prior context_token)
bot.send.await?;
// Typing indicator
bot.send_typing.await?;
Lifecycle
// Start polling (blocks)
bot.run.await?;
// Stop
bot.stop.await;
Error Handling
use WeChatBotError;
match result
AES-128-ECB Crypto
use ;
// Generate key
let key = generate_aes_key;
// Encrypt/decrypt
let ciphertext = encrypt_aes_ecb;
let plaintext = decrypt_aes_ecb?;
// Decode protocol key (handles all 3 formats)
let key = decode_aes_key?;
let key = decode_aes_key?;
Types
All protocol types derive Serialize + Deserialize + Clone + Debug:
// Wire-level (protocol)
WireMessage, WireMessageItem, CDNMedia, TextItem, ImageItem, ...
// Parsed (user-friendly)
IncomingMessage, ImageContent, VoiceContent, FileContent, VideoContent
// Auth
Credentials
// Enums
MessageType, MessageState, MessageItemType, ContentType, MediaType
Testing
License
MIT