Skip to main content

shlack

GitHub Actions status codecov PyPI - Python Version PyPI

shlack is a command line tool which sends slack messages. It is a lot like jarjar but with a few (important?) differences.

Quickstart

First, set up a slack app for shlack and have the oauth API token handy.

Then install shlack to your python 2.7, 3.5, 3.6, or 3.7 environment:

pip install shlack

Or

pip install git+https://github.com/nolanbconaway/shlack.git

Export your slack oauth token:

$ export SLACK_OAUTH_API_TOKEN='...'

Now send yourself a message! shlack will read your token from the variable you exported.

$ shlack message 'Hello!' --channel '@nolan'

In your slack workspace:

Add an attachment:

$ shlack message 'Hello!' -c '@nolan' --attach 'Date' "$(date)"

shlack can also send you a notification after a long-running task has completed.

$ shlack task 'sleep 10 && echo done' --channel '@nolan'

Running that will spin up a process detached from your terminal session, so you can grab some lunch :-).

Need help? Just ask:

$ shlack task --help

Setting up a Slack App

Start by heading over to the apps page and hit the "create new app" button.

Name your app whatever you want (I called mine, shlack ) and assign it to your workspace of choice if you have multiple workspaces. Then hit "create app".

Slack should take you to an app management page. Hit the "Permissions" button (or the "OAuth & Permissions" tab on the sidebar).

Scroll down to the "Scopes" section. Add the following two scopes:

  1. chat:write:bot . Shlack needs this to post messages.
  2. files:write:user . Shlack needs this to upload files when e.g., your task output is very long.

Hit the "Save Changes" button once those two scopes are selected. Then scroll to the top of the page and hit the "Install App to Workspace" button. Slack will ask you to allow the app to access the scopes you set up.

The page will refresh and at the top you'll find a new OAuth Access Token. Copy that and put it somewhere for later.

Now you can style the app as you see fit :). Hit the "Basic Information" tab at the top of the sidebar and scroll down to the "Display Information" section. Style to your liking. I use this photo which I found by searching "dog with cowboy hat" on the internet.

Then you're done! Enjoy your shlack app.

Todo

  • Write some tooling to help users through errors when their display names are not the same as their usernames. Maybe a command to search users. Maybe just some documentation.
  • Surface child PID to user in shlack task .
  • get URLs in attachments to unfurl.
  • migrate to blocks https://api.slack.com/messaging/attachments-to-blocks
  • pypi

Metadata

Release files for shlack 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shlack 0.1.1
File Size Uploaded
shlack-0.1.1.tar.gz 8.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for shlack 0.1.1
File Interpreter ABI Platform
shlack-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 17.7 kB

Release files / shlack-0.1.1.tar.gz

Download URL shlack-0.1.1.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9d9220f142616d5393e78d01aae04a7d0a50f4de65c8063a5818c5535276efeb
BLAKE2b-256 checksum
How to use checksums
48f877513064c4c4274dec5132fd517e8d522c62615f6c7b203c86c9eeda598e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Release files / shlack-0.1.1-py3-none-any.whl

Download URL shlack-0.1.1-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8648fdeebf552fab864001f0cd6b5c3c05e6a30ce0b44dc4d43ceea3c548f402
BLAKE2b-256 checksum
How to use checksums
e980add2e6fa7b27a7a4878506a531799b7c648dd515e9451f53c77c4ec0b29f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page