feat: add wecom support
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "dingtalk"
|
name = "dingtalk"
|
||||||
version = "2.0.0"
|
version = "2.0.1"
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "DingTalk Robot Util, Send text/markdown/link messages using DingTalk robot, 钉钉机器人"
|
description = "DingTalk Robot Util, Send text/markdown/link messages using DingTalk robot, 钉钉机器人"
|
||||||
|
|||||||
12
src/lib.rs
12
src/lib.rs
@@ -1,10 +1,4 @@
|
|||||||
use std::{
|
use std::{ fs, env, path::PathBuf, time::SystemTime, io::{ Error, ErrorKind } };
|
||||||
fs,
|
|
||||||
env,
|
|
||||||
path::PathBuf,
|
|
||||||
time::SystemTime,
|
|
||||||
io::{ Error, ErrorKind },
|
|
||||||
};
|
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use sha2::Sha256;
|
use sha2::Sha256;
|
||||||
use hmac::{ Hmac, Mac };
|
use hmac::{ Hmac, Mac };
|
||||||
@@ -198,6 +192,8 @@ impl DingTalk {
|
|||||||
Ok(Self::new(access_token, sec_token))
|
Ok(Self::new(access_token, sec_token))
|
||||||
} else if token.starts_with("wechatwork:") {
|
} else if token.starts_with("wechatwork:") {
|
||||||
Ok(Self::new_wechat(&token["wechatwork:".len()..]))
|
Ok(Self::new_wechat(&token["wechatwork:".len()..]))
|
||||||
|
} else if token.starts_with("wecom:") {
|
||||||
|
Ok(Self::new_wechat(&token["wecom:".len()..]))
|
||||||
} else {
|
} else {
|
||||||
Err(Box::new(Error::new(ErrorKind::Other, format!("Tokne format erorr: {}", token))))
|
Err(Box::new(Error::new(ErrorKind::Other, format!("Tokne format erorr: {}", token))))
|
||||||
}
|
}
|
||||||
@@ -234,7 +230,7 @@ impl DingTalk {
|
|||||||
}
|
}
|
||||||
let type_str = json_value["type"].as_str().unwrap_or_default().to_lowercase();
|
let type_str = json_value["type"].as_str().unwrap_or_default().to_lowercase();
|
||||||
let dingtalk_type = match type_str.as_str() {
|
let dingtalk_type = match type_str.as_str() {
|
||||||
"wechat" | "wechatwork" => DingTalkType::WeChatWork,
|
"wechat" | "wechatwork" | "wecom" => DingTalkType::WeChatWork,
|
||||||
_ => DingTalkType::DingTalk,
|
_ => DingTalkType::DingTalk,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user