slackify¶
Send updates to Slack about your pipeline’s progression!
You can upload a file, image, or send a message to a slack channel once you’ve gone through Slack to generate an API KEY.
The bot you create (if you choose that route) must be invited to the channel you post from the bot in.
After generating an apikey, it’s best to create a configuration file so that you can easily keep up with your apikey. Make sure to practice secure methods. Don’t upload your apikey to github as that is very insecure. Keep a local copy of your key.
Examples¶
Import the class and set up the slack handler¶
from OrthoEvol.Tools.slackify import Slackify
slack = Slackify(slackconfig='path/to/slackconfig.cfg')
Your config file should look as such:
[APIKEYS]
slack = apikeystring
Message a channel and link to a user with <@username>
in your message¶
message_to_channel = 'Hey, <@username>. This is an update for the current script.'
slack.send_msg(channel='channelname', message=message_to_channel)
Get all users and channels¶
slack.list_users() # Returns a list of all users.
slack.list_channels() # Returns a list of channels