Created
December 20, 2024 22:24
-
-
Save darenr/b81ac031938d89e7d790734c64b34e63 to your computer and use it in GitHub Desktop.
post message to discord channel
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
| from sys import argv | |
| import requests | |
| def send_to_discord(message: str): | |
| webhook_url = os.getenv("RC_WEBHOOK") | |
| if webhook_url: | |
| r = requests.post(webhook_url, json={"content": message}) | |
| r.raise_for_status() | |
| else: | |
| raise KeyError("RC_WEBHOOK not found in environment") | |
| if __name__ == "__main__": | |
| message = argv[1] if len(argv) > 1 else "Test message from python" | |
| send_to_discord(message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment