Skip to main content

Yet another slack command line interface.

Project description

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

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.1.1.tar.gz (8.8 kB view hashes)

Uploaded Source

Built Distribution

shlack-0.1.1-py3-none-any.whl (8.9 kB view hashes)

Uploaded Python 3

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