discord
This commit is contained in:
0
discord/README.md
Normal file
0
discord/README.md
Normal file
32
discord/discord.py
Normal file
32
discord/discord.py
Normal file
@@ -0,0 +1,32 @@
|
||||
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()
|
||||
9
discord/pyproject.toml
Normal file
9
discord/pyproject.toml
Normal file
@@ -0,0 +1,9 @@
|
||||
[project]
|
||||
name = "discord"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"requests>=2.32.5",
|
||||
]
|
||||
Reference in New Issue
Block a user