proc_qq

Crates.ioproc_qq
lib.rsproc_qq
version0.1.36
sourcesrc
created_at2022-05-09 09:12:12.531657
updated_at2023-04-17 07:26:17.82029
descriptionQQ client framework
homepage
repositoryhttps://github.com/niuhuan/rust_proc_qq
max_upload_size
id583121
size113,157
(niuhuan)

documentation

README

PROC_QQ

  • Rust语言的QQ机器人框架.
  • 开箱即用, 操作简单, 代码极简

相关链接

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" 你好 -> 回复:"世界"

Commit count: 166

cargo fmt