raena-crawler-engine/noon_crawler_engine/test_slack.py

21 lines
563 B
Python
Raw Normal View History

2024-01-24 13:05:07 +00:00
import requests
import json
def slack_notification(message):
webhook_url = "https://hooks.slack.com/services/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"
slack_data = {"text": message}
response = requests.post(
webhook_url, data=json.dumps(slack_data),
headers={"Content-Type": "application/json"}
)
if response.status_code != 200:
raise ValueError(
f"Request to Slack returned an error {response.status_code}, {response.text}"
)
message = "Hello from Python!"
slack_notification(message)