Created
December 4, 2021 21:00
-
-
Save FBosler/0d961b33f6c11833eab56062d5b0f0d1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 requests | |
import os | |
from dotenv import load_dotenv | |
from datetime import datetime | |
load_dotenv() | |
def send_sms(msg: str) -> None: | |
URL = os.getenv("SLACK_WEBHOOK") | |
headers = {"content-type": "application/json"} | |
payload = { | |
"attachments": [ | |
{ | |
"fallback": "Plain-text summary of the attachment.", | |
"color": "#fff", | |
"title": "🚨 Important notification", | |
"text": msg, | |
"title_link": f"https://medium.com/@fabianbosler/membership", | |
"footer": "Made by Fabian with ❤️", | |
"footer_icon": "https://image.flaticon.com/icons/png/512/2097/2097443.png", | |
"ts": datetime.utcnow().timestamp(), | |
} | |
] | |
} | |
requests.post(URL, json=payload, headers=headers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment