1 个不稳定版本

0.1.0 2020年6月24日

#12 in #ms

Download history 14/week @ 2023-12-06 29/week @ 2023-12-13 1/week @ 2023-12-20 2/week @ 2024-01-03 27/week @ 2024-01-10 1/week @ 2024-01-17 3/week @ 2024-01-24 2/week @ 2024-01-31 8/week @ 2024-02-07 29/week @ 2024-02-14 22/week @ 2024-02-21 18/week @ 2024-02-28 57/week @ 2024-03-06 37/week @ 2024-03-13 92/week @ 2024-03-20

每月209次下载

Apache-2.0

22KB
188

MHteams

Crates.io latest version Crates.io downloads GitHub license

MHteams 提供了一种简单且惯用的方法来创建和发送消息到 MS Teams webhooks。

基于官方消息卡文档

查看crate 文档

变更日志

v0.1.0

* Initial release

lib.rs:

MS Teams 消息的惯用构建。

本模块的大部分文档来自微软文档

目标

通过 MS Teams 消息的 Message 对象提供简单构建。该 Message 对象是可序列化的,使用 Serde,允许将其转换为 JSON 并发送到 Teams webhook。

示例

extern crate mhteams;
extern crate reqwest;

use mhteams::{Message, Section, Image};
use reqwest::blocking::Client;

let msg = Message::new()
    .title("My title 😉")
    .text("TL;DR: it's awesome 👍")
    .sections(vec![
        Section::new()
            .title("The **Section**")
            .activity_title("_Check this out_")
            .activity_subtitle("It's awesome")
            .activity_image("https://sweet.image/cute.png")
            .activity_text("Lorum ipsum!")
            .hero_image(Image::new("MyImage", "https://sweet.image/bigasscar.png")),
        Section::new()
            .title("Layin down some facts ✅")
            .facts(vec![
                Fact::new("Name", "John Smith"),
                Fact::new("Language", "Rust. What else?"),
            ]),
    ]);

let client = Client::new();
let resp = client
    .post(URL)
    .json(&msg)
    .send()?;

依赖关系

~0.4–1MB
~24K SLoC