#team #message #ms #microsoft #section #image

rusteams

Creating MS Teams messages

1 stable release

1.0.2 May 26, 2023
1.0.0 May 15, 2023
0.1.0 Jan 7, 2023

#3 in #teams

Apache-2.0

21KB
188 lines

Fork of MHteams This doesn't add any functionality and will not be maintained. Please use upstream


lib.rs:

Most documentation in this module are from microsoft docs.

Goal

Provide easy building of a MS Teams messages, through the Message object. The Message object is serializable, using Serde, allowing it to be converted to JSON and sent to a Teams webhook.

Example

 
 #[tokio::main]
 # async fn main() -> Result<(), reqwest::Error> {
 extern crate mhteams;
 extern crate reqwest;
 
 use mhteams::{Message, Section, Image};
 use reqwest::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()
     .await?;
 
 # Ok(())
 # }

Dependencies

~2.4–4MB
~70K SLoC