Skip to main content

wechat_ilink/
lib.rs

1//! # wechat-ilink
2//!
3//! WeChat iLink protocol client for Rust.
4//!
5//! ## Quick Start
6//!
7//! ```rust,no_run
8//! use std::sync::Arc;
9//!
10//! use wechat_ilink::{LoginQrEvent, WechatIlinkClient};
11//!
12//! #[tokio::main]
13//! async fn main() -> wechat_ilink::Result<()> {
14//!     let client = Arc::new(WechatIlinkClient::builder().build());
15//!
16//!     let mut login = client.login_qr();
17//!     while let Some(event) = login.next().await {
18//!         match event? {
19//!             LoginQrEvent::QrCode { content } => eprintln!("scan QR: {content}"),
20//!             LoginQrEvent::Confirmed { credentials } => {
21//!                 // Persist credentials in your application store.
22//!                 let _ = credentials;
23//!                 break;
24//!             }
25//!             LoginQrEvent::NeedVerifyCode { responder, .. } => {
26//!                 let _ = responder.cancel();
27//!             }
28//!             LoginQrEvent::StatusChanged { .. } => {}
29//!         }
30//!     }
31//!
32//!     drop(login);
33//!
34//!     let mut events = client.events_from_cursor(None);
35//!     while let Some(event) = events.next().await {
36//!         println!("{:?}", event?);
37//!     }
38//!     Ok(())
39//! }
40//! ```
41
42pub mod bot;
43pub mod cdn;
44pub mod crypto;
45pub mod error;
46mod markdown_filter;
47pub mod protocol;
48pub mod types;
49
50pub use bot::{
51    LoginQrEvent, LoginQrStream, SendContent, SendReceipt, UserInteractionReason,
52    VerifyCodeResponder, WechatEvent, WechatEventStream, WechatIlinkClient,
53    WechatIlinkClientBuilder, WechatRateLimitOptions,
54};
55pub use cdn::CdnClient;
56pub use crypto::{
57    decode_aes_key, decrypt_aes_ecb, decrypt_aes_ecb as download_decrypt, encode_aes_key_base64,
58    encode_aes_key_hex, encrypt_aes_ecb, generate_aes_key,
59};
60pub use error::{Result, WechatIlinkError};
61pub use markdown_filter::filter_markdown;
62pub use protocol::{
63    build_cdn_upload_url, BaseInfo, GetConfigResponse, GetUpdatesResponse, GetUploadUrlParams,
64    GetUploadUrlResponse, ILinkClientOptions, NotifyStartResponse, NotifyStopResponse,
65};
66pub use types::*;