A notification for slackers
slacker [OPTIONS] MESSAGE
Slacker CLI tool to send a message using the send_message function from
utils.
Options:
--help Show this message and exit.
Example:
sleep 5 && slacker "Hello World after 5 seconds!"
Python example:
from time import sleep
from slacker.utils import send_message
a = 0
for i in range(5):
a+=1
sleep(1)
send_message('Done!')
send_message(f'a = {a}')
Use cases:
- Install in an ipykernel and call
send_message
to notify you on status of jupyter notebook code blocks. - Implement into a shell function to notify you of exit status of a command that takes a long time to run.
- Other actions involving python or shell where one might benefit from a slack messge.
Clone the repo and enter the directory. Then run:
pip install -e .
You will need a bot token from slack. Go to the slack app page
- Click create new app
- Choose "from scratch"
- Give it a name and choose workspace.
- On the basic information page, scroll down to edit name and add custom app icon.
- On the management sidebar of the app, click "OAuth & Permissions".
- Scroll down to Scopes and add a bot token scope. Choose the
chat:write
permission for the bot token scope. - Install app to workspace by clicking the install to workspace button. This will provide you the "Bot User Oauth Token".
- By having an editable install with
pip install -e .
, we then need to modify lines inslacker/config.py
to add the oauth token as well as give the bot the name you chose. - In the Slack app, right click on the conversation you want the bot to post in (could be the bot's channel or your personal channel) and choose
view conversation details
- Note the
Channel ID
and editslacker/config.py
to the correct channel ID. - Start sending messages!
slacker
was written by Andy Zhou <andy.zhou@czbiohub.org>
.