rust-slack

A rust crate for sending messages to Slack via webhooks.

Slack is a messaging platform for team collaboration.

Build Status

Usage

Add this to your Cargo.toml:

toml [dependencies] slack-hook = "*"

Add the crate to your existing project:

```rust extern crate slackhook; use slackhook::{Slack, Payload, PayloadTemplate};

fn main() { let slack = Slack::new("https://hooks.slack.com/services/abc/123/45z"); let p = Payload::new(PayloadTemplate::Complete { text: Some("test message"), channel: Some("#testing"), username: Some("My Bot"), iconurl: None, iconemoji: Some(":chartwithupwardstrend:"), attachments: None, unfurllinks: Some(true), link_names: Some(false) });

let res = slack.send(&p);
match res {
    Ok(()) => println!("ok"),
    Err(x) => println!("ERR: {:?}",x)
}

} ```

Attachments

To create a payload with just an attachment:

```rust extern crate slackhook; use slackhook::{Payload, PayloadTemplate, Attachment, AttachmentTemplate};

fn main() { let p = Payload::new(PayloadTemplate::Attachment { attachment: Attachment::new(AttachmentTemplate::Text { text: "my text", color: "#b13d41", }).unwrap(), }); } ```

Documentation

rust-slack documentation

License

This library is distributed under similar terms to Rust: dual licensed under the MIT license and the Apache license (version 2.0).

See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details.