DingTalk Robot Util, Send text/markdown/link messages using DingTalk robot
钉钉机器人 Rust SDK
NOTE: From version 1.1.0 dingtalk uses reqwest 0.10.0's async
/.await
API.
Official reference: https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq/0fa88adc
Sample 1: ```rust use dingtalk::DingTalk;
pub async fn main() -> Result<(), Box
Ok(())
} ```
Need use crate: tokio = { version = "0.2.6", features = ["full"] }
.
Sample 2 (Read token from file): ```rust
pub async fn main() -> Result<(), Box
Ok(())
} ```
Sample, send markdown message:
rust
dt.send_markdown("markdown title 001", r#"# markdown content 001
* line 0
* line 1
* line 2"#).await?;
Sample, send link message:
rust
dt.send_link("link title 001", "link content 001", "https://hatter.ink/favicon.png", "https://hatter.ink/").await?;
Sample, send feed card message:
rust
dt.send_message(&DingTalkMessage::new_feed_card()
.add_feed_card_link(DingTalkMessageFeedCardLink{
title: "test feed card title 001".into(),
message_url: "https://hatter.ink/".into(),
pic_url: "https://hatter.ink/favicon.png".into(),
})
.add_feed_card_link(DingTalkMessageFeedCardLink{
title: "test feed card title 002".into(),
message_url: "https://hatter.ink/".into(),
pic_url: "https://hatter.ink/favicon.png".into(),
})
).await?;
Sample, send action card message(single btn):
rust
dt.send_message(&DingTalkMessage::new_action_card("action card 001", "action card text 001")
.set_action_card_signle_btn(DingTalkMessageActionCardBtn{
title: "test signle btn title".into(),
action_url: "https://hatter.ink/".into(),
})
).await?;
Sample, send action card message(multi btns):
rust
dt.send_message(&DingTalkMessage::new_action_card("action card 002", "action card text 002")
.add_action_card_btn(DingTalkMessageActionCardBtn{
title: "test signle btn title 01".into(),
action_url: "https://hatter.ink/".into(),
})
.add_action_card_btn(DingTalkMessageActionCardBtn{
title: "test signle btn title 02".into(),
action_url: "https://hatter.ink/".into(),
})
).await?;
DingTalk config:
json
{
"access_token": "<access token>",
"sec_token": "<sec token>"
}
WeChat Work config:
json
{
"type": "wechat",
"access_token": "<token>"
}
DingTalk::new_wechat
"type": "wechat"
, supports method DingTalk::send_text
maplit
crateserde
and serde_json
crates, replace json
cratehmac
and sha2
crates, replace rust-crypto
crateDingTalk::from_json
add direct_url
TEXT
-> Text
..., change enum capsActionCard
message, send action card message typedirect_url
for DingTalk
, for outgoing robotFeedCard
message, send feed card message typeDingtalk::from_json
, read token from JSON stringDingTalk::from_file
, read token from fileDefault::default()
supportset_default_webhook_url
, default dingtalk webhook urlDingTalk::send_link(...)
, send link messageDingTalkMessage
, can set at_all
, at_mobiles
now