Created
July 13, 2020 06:32
-
-
Save s9k96/06ded6d32f2d003840dc7f6208235301 to your computer and use it in GitHub Desktop.
Send notifications to a slack channel through slack webhooks.
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
# Send notifications to a slack channel through slack webhooks. | |
import requests | |
import json | |
webhook = '' # Slack channel webhook. | |
def notify_slack(message): | |
""" | |
Send a string to slack channel. | |
message: str | |
""" | |
data= { | |
'text' : message | |
} | |
try: | |
requests.post(webhook, json.dumps(data)) | |
except: | |
print("[ERROR] Not able to execute slack notification.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment