slack-hook 0.0.3

A rust crate for sending messages to Slack via webhooks.
docs.rs failed to build slack-hook-0.0.3
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: slack-hook-0.8.0

rust-slack

A rust crate for sending messages to Slack via webhooks.

Slack is a messaging platform for team collaboration.

Build Status

Usage

Add the crate to your existing project:

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"),
      icon_url: None,
      icon_emoji: Some(":chart_with_upwards_trend:"),
      attachments: None,
      unfurl_links: 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:

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.