From c61e113d960e81db8a010acf66c933cade2fbd21 Mon Sep 17 00:00:00 2001 From: Dima Marhitych Date: Tue, 22 Aug 2023 22:33:58 +0200 Subject: [PATCH] Discord module is finally back --- .gitignore | 3 --- discord/discord_req.txt | 3 +++ discord/send_webhook.py | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 discord/discord_req.txt create mode 100644 discord/send_webhook.py diff --git a/.gitignore b/.gitignore index 3919ac6..9b49434 100644 --- a/.gitignore +++ b/.gitignore @@ -167,6 +167,3 @@ cython_debug/ compile/ **/.DS_Store -# Discord webhooks -discord/ - diff --git a/discord/discord_req.txt b/discord/discord_req.txt new file mode 100644 index 0000000..0e81be6 --- /dev/null +++ b/discord/discord_req.txt @@ -0,0 +1,3 @@ +fusion-engine +python-dotenv +discord_webhook \ No newline at end of file diff --git a/discord/send_webhook.py b/discord/send_webhook.py new file mode 100644 index 0000000..46bd2b4 --- /dev/null +++ b/discord/send_webhook.py @@ -0,0 +1,24 @@ +from discord_webhook import DiscordWebhook +import fusionengine as fusion +import os +from dotenv import load_dotenv + +load_dotenv() + + +def send_discord_webhook(message): + webhook = os.environ.get("DISCORD_WEBHOOK") + + if webhook: + webhook = DiscordWebhook(url=webhook, content=message) + webhook.execute() + else: + print("Discord webhook URL not found in environment variables.") + + +version = fusion.__version__ +author = fusion.__author__ + +message = f"Fusion Engine {version} of package has been released to PyPI by {author}! Check it out at https://pypi.org/project/fusion-engine/{version}" + +send_discord_webhook(message)