v1.0.1
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "dingtalk"
|
name = "dingtalk"
|
||||||
version = "1.0.0"
|
version = "1.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, 钉钉机器人"
|
||||||
keywords = ["DingTalk", "Robot", "Message"]
|
keywords = ["DingTalk", "Robot", "Message", "钉钉", "机器人"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://git.hatter.ink/hatter/dingtalk"
|
repository = "https://git.hatter.ink/hatter/dingtalk"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|||||||
56
README.md
56
README.md
@@ -25,9 +25,65 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Sample, send markdown message:
|
||||||
|
```rust
|
||||||
|
dt.send_markdown("markdown title 001", r#"# markdown content 001
|
||||||
|
* line 0
|
||||||
|
* line 1
|
||||||
|
* line 2"#)?;
|
||||||
|
```
|
||||||
|
|
||||||
|
Sample, send link message:
|
||||||
|
```rust
|
||||||
|
dt.send_link("link title 001", "link content 001", "https://hatter.ink/favicon.png", "https://hatter.ink/")?;
|
||||||
|
```
|
||||||
|
|
||||||
|
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(),
|
||||||
|
})
|
||||||
|
)?;
|
||||||
|
```
|
||||||
|
|
||||||
|
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(),
|
||||||
|
})
|
||||||
|
)?;
|
||||||
|
```
|
||||||
|
|
||||||
|
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(),
|
||||||
|
})
|
||||||
|
)?;
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
#### Changelog
|
#### Changelog
|
||||||
|
|
||||||
|
* v1.0.1
|
||||||
|
* change two fn names
|
||||||
|
* Add readme sample codes
|
||||||
* v1.0.0
|
* v1.0.0
|
||||||
* `TEXT` -> `Text` ..., change enum caps
|
* `TEXT` -> `Text` ..., change enum caps
|
||||||
* Add `ActionCard` message, send action card message type
|
* Add `ActionCard` message, send action card message type
|
||||||
|
|||||||
54
src/lib.rs
54
src/lib.rs
@@ -232,13 +232,13 @@ impl <'a> DingTalkMessage<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Set action card single btn
|
/// Set action card single btn
|
||||||
pub fn action_card_signle_btn(mut self, btn: DingTalkMessageActionCardBtn) -> Self {
|
pub fn set_action_card_signle_btn(mut self, btn: DingTalkMessageActionCardBtn) -> Self {
|
||||||
self.action_card_single_btn = Some(btn);
|
self.action_card_single_btn = Some(btn);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add action card btn
|
/// Add action card btn
|
||||||
pub fn action_card_add_btn(mut self, btn: DingTalkMessageActionCardBtn) -> Self {
|
pub fn add_action_card_btn(mut self, btn: DingTalkMessageActionCardBtn) -> Self {
|
||||||
self.action_card_btns.push(btn);
|
self.action_card_btns.push(btn);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
@@ -490,3 +490,53 @@ fn calc_hmac_sha256(key: &[u8], message: &[u8]) -> MacResult {
|
|||||||
hmac.input(message);
|
hmac.input(message);
|
||||||
hmac.result()
|
hmac.result()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn run_all_tests() {
|
||||||
|
_test_send().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn _test_send() -> XResult<()> {
|
||||||
|
let dt = DingTalk::from_file("~/.dingtalk-token.json")?;
|
||||||
|
dt.send_text("test message 001 ---------------------")?;
|
||||||
|
|
||||||
|
dt.send_markdown("markdown title 001", r#"# markdown content 001
|
||||||
|
* line 0
|
||||||
|
* line 1
|
||||||
|
* line 2"#)?;
|
||||||
|
|
||||||
|
dt.send_link("link title 001", "link content 001", "https://hatter.ink/favicon.png", "https://hatter.ink/")?;
|
||||||
|
|
||||||
|
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(),
|
||||||
|
})
|
||||||
|
)?;
|
||||||
|
|
||||||
|
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(),
|
||||||
|
})
|
||||||
|
)?;
|
||||||
|
|
||||||
|
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(),
|
||||||
|
})
|
||||||
|
)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user