Created
June 16, 2017 19:55
-
-
Save samuelstevens9/ef37ac880dbf31200d41b831342c8d95 to your computer and use it in GitHub Desktop.
Python Requests Post Slack Message
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
""" | |
https://api.slack.com/incoming-webhooks#sending_messages | |
{ | |
"text":"Read <https://api.slack.com/incoming-webhooks#sending_messages|Send Slack Message> for more details @slackuser #general" | |
"link_names": 1 | |
} | |
""" | |
import requests,json | |
def slack_message(message_text=None,payload_obj=None,slack_url=None): | |
if(not slack_url): | |
slack_url = "https://hooks.slack.com/services/.../.../..." | |
if(not payload_obj and message_text): | |
payload_obj = {"text":message_text,"link_names":1} | |
r = requests.put(slack_url,data=json.dumps(payload_obj)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment