Skip to content

Instantly share code, notes, and snippets.

@FBosler
Created December 4, 2021 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FBosler/0d961b33f6c11833eab56062d5b0f0d1 to your computer and use it in GitHub Desktop.
Save FBosler/0d961b33f6c11833eab56062d5b0f0d1 to your computer and use it in GitHub Desktop.
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