From dbb42330584bec4b6cdda49ea60ae4a02b9f6822 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 24 Aug 2023 13:42:10 +1000 Subject: [PATCH] bot: Parse new licence api --- README.md | 2 +- discord-bot/bot.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fc70d97..8f46255 100644 --- a/README.md +++ b/README.md @@ -53,5 +53,5 @@ curl -X POST http://master-server-ip:5000/add-worker?worker=worker-name&ip=worke Docker install ``` -docker run -d -e MASTER_IP= -e DISCORD_TOKEN= -e LICENCE-API=your-api-key -e WORKER_KEY=your-api-key --name hnshosting-bot git.woodburn.au/nathanwoodburn/hnshosting-bot:latest +docker run -d -e MASTER_IP= -e DISCORD_TOKEN= -e LICENCE_KEY=your-api-key -e WORKER_KEY=your-api-key --name hnshosting-bot git.woodburn.au/nathanwoodburn/hnshosting-bot:latest ``` \ No newline at end of file diff --git a/discord-bot/bot.py b/discord-bot/bot.py index 4d644f7..f1ce7e1 100644 --- a/discord-bot/bot.py +++ b/discord-bot/bot.py @@ -41,7 +41,6 @@ async def listworkers(ctx): await ctx.response.send_message(json['workers'],ephemeral=True) else: await ctx.response.send_message(f"Error listing workers\n" + json['error'],ephemeral=True) - await ctx.response.send_message(r.text,ephemeral=True) else: await ctx.response.send_message(f"Error listing workers\n" + r.text,ephemeral=True) else: @@ -56,7 +55,11 @@ async def license(ctx): r = requests.post(f"http://{Master_IP}:{Master_Port}/add-licence",headers={"key":os.getenv('LICENCE_KEY')}) if r.status_code == 200: - await ctx.response.send_message(r.text,ephemeral=True) + json = r.json() + if json['success'] == "true": + await ctx.response.send_message(json['licence_key']) + else: + await ctx.response.send_message(f"Error getting license\n" + json['error']) else: await ctx.response.send_message(f"Error getting license\n" + r.text,ephemeral=True)