wx-work

Crates.iowx-work
lib.rswx-work
version0.2.0
sourcesrc
created_at2020-10-01 11:00:38.919018
updated_at2021-05-27 03:43:32.989868
description企业微信 sdk
homepagehttps://github.com/nooberfsh/wx-work
repositoryhttps://github.com/nooberfsh/wx-work
max_upload_size
id294980
size96,000
tom (nooberfsh)

documentation

https://docs.rs/wx-work

README

企业微信 sdk

使用

# Cargo.toml
[dependencies]
wx-work = "0.2"

Example: 上传文件

use wx_work::client::Client;
use wx_work::media::FileType;

#[tokio::main]
async fn main() {
    let corp_id = "";
    let secret_id = "";

    let cli = Client::new(corp_id, secret_id).unwrap();
    cli.upload_file(FileType::Video, "path/to/file")
        .await
        .unwrap();
}

Example: echo 服务器

use async_trait::async_trait;
use wx_work::server::{App, Builder, RecvMessage, RecvMessageType, SendMessage};

struct MyApp;

#[async_trait]
impl App for MyApp {
    async fn handle(&self, msg: RecvMessage) -> Option<SendMessage> {
        match msg.msg_ty {
            RecvMessageType::Text(x) => Some(SendMessage::new_text(x, msg.from_user_name, msg.to_user_name)),
            _ => None,
        }
    }
}

#[tokio::main]
async fn main() {
    let token = "";
    let aes_key = "";
    let server = Builder::new(MyApp, token, aes_key).build().unwrap();
    server.run().await.unwrap();
}

License

MIT

Commit count: 53

cargo fmt