import requests import sys import os def send_discord_alert(): # It's best practice to keep your webhook URL in an environment variable # especially for an InfoSec Officer! webhook_url = os.getenv("DISCORD_ALERTS_URL") if not webhook_url: print("Error: Please set the DISCORD_ALERTS_URL environment variable.") sys.exit(1) # Join all command line arguments into one string # If no arguments, send a default message message = " ".join(sys.argv[1:]) if len(sys.argv) > 1 else "Security check: Python Webhook is active. 🐍" payload = { "content": message, "username": "Jared Mac Laptop", # You can customize the name here "avatar_url": "https://zappy.jaredlog.com/apple-logo-icon-bw.jpg" # Optional: add a custom bot icon } try: response = requests.post(webhook_url, json=payload) response.raise_for_status() except requests.exceptions.RequestException as e: print(f"Failed to send message: {e}") sys.exit(1) if __name__ == "__main__": send_discord_alert()