Skip to main content

Yet another slack command line interface.

Project description

shlack

GitHub Actions status codecov

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 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shlack-0.0.1.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

shlack-0.0.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file shlack-0.0.1.tar.gz.

File metadata

  • Download URL: shlack-0.0.1.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for shlack-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f9b218dd06a8a713d6373198b02395365b2cea7b717b19bd1173aaa3e30cd29b
MD5 b4063d9ca4f4dfaf760c79fc593ebc8f
BLAKE2b-256 c371e074d08e5351c6d3f87350ee19bfc8308f3cf13a1ec68528bd86469d1135

See more details on using hashes here.

File details

Details for the file shlack-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: shlack-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for shlack-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a37c69f32cab6e5156e2d34589de005be656a13441676a73e7f4d0fe9e8198ee
MD5 0792d42e34ac91c737a1984891bb1971
BLAKE2b-256 a684c2ac7059fdf6f2132ea089ec46d1bd199a078f4c78dd06cbc5bb650ee284

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page