bot: Adding a few catches to the bot
This commit is contained in:
parent
e241f6ffeb
commit
9c5b00433f
@ -71,6 +71,14 @@ async def license(ctx):
|
|||||||
|
|
||||||
@tree.command(name="createsite", description="Create a new WordPress site")
|
@tree.command(name="createsite", description="Create a new WordPress site")
|
||||||
async def createsite(ctx, domain: str, licence: str = None):
|
async def createsite(ctx, domain: str, licence: str = None):
|
||||||
|
# Verify domain is valid
|
||||||
|
if domain == None:
|
||||||
|
await ctx.response.send_message("You must specify a domain",ephemeral=True)
|
||||||
|
return
|
||||||
|
if "http://" in domain or "https://" in domain:
|
||||||
|
await ctx.response.send_message("You must specify a domain without http:// or https://",ephemeral=True)
|
||||||
|
return
|
||||||
|
|
||||||
if FREE_LICENCE == True: # If free licences are enabled then auto generate a licence
|
if FREE_LICENCE == True: # 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')})
|
r = requests.post(f"http://{Master_IP}:{Master_Port}/add-licence",headers={"key":os.getenv('LICENCE_KEY')})
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
@ -85,7 +93,7 @@ async def createsite(ctx, domain: str, licence: str = None):
|
|||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
json = r.json()
|
json = r.json()
|
||||||
if json['success'] == "true":
|
if json['success'] == "true":
|
||||||
await ctx.response.send_message(f"Site {domain} creating...\nI'll send you a message when it's ready")
|
await ctx.response.send_message(f"Site https://{domain} creating...\nI'll send you a message when it's ready")
|
||||||
|
|
||||||
ready = False
|
ready = False
|
||||||
while ready == False:
|
while ready == False:
|
||||||
@ -96,7 +104,7 @@ async def createsite(ctx, domain: str, licence: str = None):
|
|||||||
r = requests.get(f"http://{Master_IP}:{Master_Port}/site-info?domain={domain}")
|
r = requests.get(f"http://{Master_IP}:{Master_Port}/site-info?domain={domain}")
|
||||||
json = r.json()
|
json = r.json()
|
||||||
if json['success'] == "true":
|
if json['success'] == "true":
|
||||||
await ctx.user.send(f"Site {domain} is ready!\nHere is the site info for {json['domain']}\nA: `{json['ip']}`\nTLSA: `{json['tlsa']}`\nMake sure you put the TLSA in either `_443._tcp.{domain}` or `*.{domain}`")
|
await ctx.user.send(f"Site https://{domain} is ready!\nHere is the site info for {json['domain']}\nA: `{json['ip']}`\nTLSA: `{json['tlsa']}`\nMake sure you put the TLSA in either `_443._tcp.{domain}` or `*.{domain}`")
|
||||||
else:
|
else:
|
||||||
await ctx.user.send(f"Error getting site info\n" + json['error'])
|
await ctx.user.send(f"Error getting site info\n" + json['error'])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user