Created
September 7, 2017 16:55
-
-
Save Lokno/777d4d6b31d6564c2806f7189c9ab213 to your computer and use it in GitHub Desktop.
Command-line utility for posting a message as a slack bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os,sys | |
from slackclient import SlackClient | |
if len(sys.argv) < 2: | |
print "usage: post_as_bot.py <message>" | |
sys.exit(-1) | |
msg = ' '.join(sys.argv[1:]) | |
BOT_NAME = 'BOTNAME' | |
slack_client = SlackClient(os.environ.get('SLACK_BOT_TOKEN')) | |
if __name__ == "__main__": | |
slack_client.api_call("chat.postMessage", channel='CHANNEL', text=msg, as_user=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment