Crates.io | proc_qq |
lib.rs | proc_qq |
version | 0.1.36 |
source | src |
created_at | 2022-05-09 09:12:12.531657 |
updated_at | 2023-04-17 07:26:17.82029 |
description | QQ client framework |
homepage | |
repository | https://github.com/niuhuan/rust_proc_qq |
max_upload_size | |
id | 583121 |
size | 113,157 |
相关链接
Example
/// 事件处理器
#[event]
async fn print(event: &MessageEvent) -> anyhow::Result<bool> {
let content = event.message_content();
if content.eq("你好") {
event
.send_message_to_source("世界".parse_message_chain())
.await?;
Ok(true)
} else if content.eq("RC") {
event
.send_message_to_source("NB".parse_message_chain())
.await?;
Ok(true)
} else if content.eq("EX") {
Err(anyhow::Error::msg("Text exception"))
} else {
Ok(false)
}
}
/// 封装模块
pub(crate) fn module() -> Module {
module!("hello", "你好", print)
}
/// 调用
#[tokio::test]
async fn test_qr_login() {
init_tracing_subscriber();
ClientBuilder::new()
.device(DeviceSource::JsonFile("device.json".to_owned()))
.version(&ANDROID_WATCH)
.authentication(QRCode)
.modules(vec![hello_module::module()])
.build()
.await
.unwrap()
.start()
.await
.unwrap()
.unwrap();
}
RC -> 回复:"NB" 你好 -> 回复:"世界"