Crates.io | block_kit |
lib.rs | block_kit |
version | 0.1.0 |
source | src |
created_at | 2019-12-13 01:32:51.59072 |
updated_at | 2019-12-13 01:59:39.236989 |
description | Simple wrapper for slack api |
homepage | https://github.com/horita-yuya |
repository | https://github.com/horita-yuya/rust_block_kit |
max_upload_size | |
id | 188954 |
size | 210,510 |
Simple wrapper for Slack API, Block Kit and Payloads for Slach Commands and Interactive Components. Implemented using serde
// export SLACK_BOT_TOKEN=xoxb-your-bot-token
// export SLACK_CHANNEL=random
let config = match from_env::<SlackConfig>() {
Ok(val) => val,
Err(err) => {
error!("{}", err);
process::exit(1);
}
};
let section = SectionBlock::new(Markdown("@here *Hello World*, `section1`".into()));
let common_payload = CommonMessagePayload::new().blocks(vec![section.into()]);
let payload = ChatPostMessagePayload::new(&config.channel, common_payload);
Sample with reqwest
let res: PostMessageResponse = reqwest::Client::new()
.post(CHAT_POST_MESSAGE_URL)
.header("Authorization", format!("Bearer {}", config.bot_token))
.json(&payload)
.send()
.await
.unwrap()
.json()
.await
.unwrap();
Block Kit is a UI framework for Slack apps that offers a balance of control and flexibility when building experiences in messages and other surfaces.
Customize the order and appearance of information and guide users through your app's capabilities by composing, updating, sequencing, and stacking blocks — reusable components that work almost everywhere in Slack.
Quoted from official docs
App Surface is anywhere an app can express itself throught communication or interaction. It may have some Blocks.
Block is a visual component. Blocks can be stacked and arranged to create layouts. The essential Block Kit building experience is the same in any surfaces.
Block may have some Block Elements and some Composition Objects. The number of elements it can have depends on the type of block. For example,
[Block Elements]
[Composition Objects]
text
and fields
.Block Element is a visual smaller component.
Elements can be used inside of section
, context
, actioons
block.
They constitutes a part of Block. Element may have some Composition Objects.
Composition Object is also a visual component, but is smaller than Block Element. It can be used inside of blocks and block elements. And, it may have some Composition Objects.
For example,
Some sentences are referred by official docs
view payloads, Home Tab
and Modals
, haven't been supported yet, but will be soon.
As described in rust-musl-builder.
alias rust-musl-builder='docker run --rm -it -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder'
rust-musl-builder cargo build --example interactive_server --release