main: Added tlsa and a few bug fixes
All checks were successful
Build Docker / Build Master (push) Successful in 26s
Build Docker / Build Bot (push) Successful in 25s

This commit is contained in:
2023-08-17 13:27:57 +10:00
parent 1f316e3a94
commit d6db4adf50
6 changed files with 65 additions and 7 deletions

View File

@@ -8,6 +8,9 @@ load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
ADMINID = 0
Master_IP = os.getenv('MASTER_IP')
Master_Port = os.getenv('MASTER_PORT')
if Master_IP == None:
Master_IP = "5000"
intents = discord.Intents.default()
client = discord.Client(intents=intents)
@@ -16,7 +19,7 @@ tree = app_commands.CommandTree(client)
@tree.command(name="addworker", description="Adds a worker to the master server")
async def addworker(ctx, ip: str, name: str):
if ctx.author.id == ADMINID:
r = requests.get(f"http://{Master_IP}:5000/add-worker?worker={name}&ip={ip}")
r = requests.get(f"http://{Master_IP}:{Master_Port}/add-worker?worker={name}&ip={ip}",headers={"key":os.getenv('WORKER_KEY')})
if r.status_code == 200:
await ctx.response.send_message(f"Worker {name} added to the master server",ephemeral=True)
else:
@@ -24,7 +27,16 @@ async def addworker(ctx, ip: str, name: str):
else:
await ctx.response.send_message("You do not have permission to use this command",ephemeral=True)
@tree.command(name="listworkers", description="Lists all workers on the master server")
async def listworkers(ctx):
if ctx.author.id == ADMINID:
r = requests.get(f"http://{Master_IP}:{Master_Port}/list-workers",headers={"key":os.getenv('WORKER_KEY')})
if r.status_code == 200:
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:
await ctx.response.send_message("You do not have permission to use this command",ephemeral=True)
# When the bot is ready
@client.event