From ec052b4ec14c069c9ef724fdf363c52e29af5cda Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 24 Aug 2023 14:25:58 +1000 Subject: [PATCH] bot: Added site info command --- discord-bot/bot.py | 14 +++++++++++++- master/main.py | 8 ++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/discord-bot/bot.py b/discord-bot/bot.py index 89cac6a..418c5a2 100644 --- a/discord-bot/bot.py +++ b/discord-bot/bot.py @@ -69,13 +69,25 @@ async def createsite(ctx, domain: str, licence: str): if r.status_code == 200: json = r.json() if json['success'] == "true": - await ctx.response.send_message(f"Site {domain} creating...\nPlease send /siteinfo domain:{domain}") + await ctx.response.send_message(f"Site {domain} creating...\nPlease wait a few minutes and then send /siteinfo domain:{domain}") else: await ctx.response.send_message(f"Error creating site\n" + json['error']) else: await ctx.response.send_message(f"Error creating site\n" + r.text) +@tree.command(name="siteinfo", description="Get info about a WordPress site") +async def siteinfo(ctx, domain: str): + r = requests.get(f"http://{Master_IP}:{Master_Port}/site-info?domain={domain}") + if r.status_code == 200: + json = r.json() + if json['success'] == "true": + await ctx.response.send_message(f"Site: {domain}\nStatus: {json['status']}\nWorker: {json['worker']}") + else: + await ctx.response.send_message(f"Error getting site info\n" + json['error']) + else: + await ctx.response.send_message(f"Error getting site info\n" + r.text) + # When the bot is ready @client.event async def on_ready(): diff --git a/master/main.py b/master/main.py index 9367bc4..edbca2b 100644 --- a/master/main.py +++ b/master/main.py @@ -203,13 +203,9 @@ def site_status(): if "tlsa" in json: tlsa = json['tlsa'] + return jsonify({'success': 'true', 'domain': domain, 'ip': ip, 'tlsa': tlsa}) else: - tlsa = "none" - - # Return status - - - return jsonify({'success': 'true', 'domain': domain, 'ip': ip, 'tlsa': tlsa}) + return jsonify({'success': 'false', 'domain': domain, 'ip': ip, 'tlsa': 'none','error': 'No TLSA record found'}) @app.route('/tlsa', methods=['GET'])