From 5049796d07d5b1067f1d910c6491ac1bea9ba449 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Fri, 25 Aug 2023 14:01:36 +1000 Subject: [PATCH] bot: Added free mode --- discord-bot/bot.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/discord-bot/bot.py b/discord-bot/bot.py index 0450dbc..7a2f855 100644 --- a/discord-bot/bot.py +++ b/discord-bot/bot.py @@ -50,9 +50,8 @@ async def listworkers(ctx): @tree.command(name="licence", description="Gets a licence key") async def license(ctx): if ctx.user.id != ADMINID: - if FREE_LICENCE == False: # If free licences are enabled then anyone can get a licence - await ctx.response.send_message("You do not have permission to use this command",ephemeral=True) - return + await ctx.response.send_message("You do not have permission to use this command",ephemeral=True) + return r = requests.post(f"http://{Master_IP}:{Master_Port}/add-licence",headers={"key":os.getenv('LICENCE_KEY')}) if r.status_code == 200: @@ -66,6 +65,16 @@ async def license(ctx): @tree.command(name="createsite", description="Create a new WordPress site") async def createsite(ctx, domain: str, licence: str): + if FREE_LICENCE == False: # If free licences are enabled then auto generate a licence + r = requests.post(f"http://{Master_IP}:{Master_Port}/add-licence",headers={"key":os.getenv('LICENCE_KEY')}) + if r.status_code == 200: + json = r.json() + if json['success'] == "true": + licence = json['licence_key'] + else: + await ctx.response.send_message(f"Error getting license\n" + json['error']) + return + r = requests.post(f"http://{Master_IP}:{Master_Port}/new-site?domain={domain}",headers={"key":licence}) if r.status_code == 200: json = r.json()