Skip to content

Instantly share code, notes, and snippets.

@0xjmux
Created November 15, 2024 18:09
Show Gist options
  • Save 0xjmux/487f58e2fd75e3eb49ea29198496f53c to your computer and use it in GitHub Desktop.
Save 0xjmux/487f58e2fd75e3eb49ea29198496f53c to your computer and use it in GitHub Desktop.
Stupid-simple message sending to discord via webhook in 6 (really 3) lines of python
import requests
# Also see: https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks
USERNAME = "Python Notifier"
WEBHOOK_URL = ""
def send_alert(contents: str):
data = {"content": contents, "username": USERNAME}
try:
requests.post(WEBHOOK_URL, json=data)
except Exception as e:
print(f"Error sending alert: {e}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment