sm - Slack Message
==================
sm is a minimal binary to send a message to a Slack channel.
Requirements
------------
In order to build sm you need rustc and libtls (LibreSSL).
Installation
------------
Edit Makefile to match your local setup (sm is installed into
the /usr/local/bin namespace by default).
Afterwards enter the following command to build and install sm:
make clean install
Running sm
----------
sm takes the channel id and the message, in this order, and posts
the message to that channel as the owner of SLACK_USER_TOKEN.
Exit status is 0 on success and non-zero on failure.
sm C03DEET2M18 "hello from sm"
The message may also be read from standard input by passing "-":
date | sm C03DEET2M18 -
Print the version:
sm -V
Formatting
----------
sm sends the message bytes verbatim. Slack renders the text as
its own mrkdwn flavor on the server side; the syntax is similar
to but not identical to CommonMark (e.g. `*bold*` instead of
`**bold**`). See the Slack formatting reference for the full
list:
https://api.slack.com/reference/surfaces/formatting
Block Kit
---------
If the message parses as JSON and is a non-empty array whose
first element is an object with a string "type" field, sm posts
it as a Block Kit "blocks" payload instead of plain text. A
static fallback "text" is sent alongside the blocks so push and
legacy notifications have something to display. Anything else,
including messages that happen to be valid JSON but do not match
that shape, is sent verbatim as text.
cat blocks.json | sm C03DEET2M18 -
See the Block Kit reference:
https://api.slack.com/reference/block-kit/blocks
Configuration
-------------
sm reads a single environment variable:
SLACK_USER_TOKEN Slack user token, e.g. xoxp-...
The token must have the chat:write scope for the target channel.
Download
--------
got clone ssh://ijanc@ijanc.org/sm
License
-------
ISC — see LICENSE.