slack-hook
A rust crate for sending messages to Slack via webhooks.
Slack is a messaging platform for team collaboration.
Upgrading? See the CHANGELOG.
Features
- blocking: Provides a synchronous "blocking" slack client
- default-tls (enabled by default): Provides TLS support to connect over HTTPS
- native-tls: Enables TLS functionality provided by
native-tls - rustls-tls: Enables TLS functionality provided by
rustls
Usage
Simply run this to add it to your Cargo.toml:
cargo add slack-hook --features=blocking
and then start sending messages!
use ;
let slack = new.unwrap;
let payload = new
.text
.channel
.username
.icon_emoji
.build
.expect;
match slack.send
Attachments
To create a payload with just an attachment:
use ;
let attachment = new
.color
.build
.unwrap;
let _payload = new
.attachments
.build
.unwrap;
Text with Links
Slack messaging API permits you to send links within text. However, given the different formatting rules, these text fragments need to be specified as follows:
use ;
let text = ;
let _ = new
.text
.build
.unwrap;
Sending this payload will display the following in slack (note: each element
of the Vec has been space-separated):
Hello Google, nice to know you.
This technique can be used for any function that has the Into<SlackText>
trait bound.
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.