bot: Add command to do a manual check
All checks were successful
Build Docker / Build Docker (push) Successful in 17s
All checks were successful
Build Docker / Build Docker (push) Successful in 17s
This commit is contained in:
parent
0ac3b1592b
commit
d54da80ab6
49
bot.py
49
bot.py
@ -393,7 +393,52 @@ async def ssldomains(ctx):
|
|||||||
await ctx.response.send_message("Domains in the SSL expiry notification list:\n" + "\n".join(domains),ephemeral=True)
|
await ctx.response.send_message("Domains in the SSL expiry notification list:\n" + "\n".join(domains),ephemeral=True)
|
||||||
|
|
||||||
|
|
||||||
|
@tree.command(name="sslremove", description="Remove a domain from the SSL expiry notification list")
|
||||||
|
async def sslremove(ctx, domain: str):
|
||||||
|
# Get user id
|
||||||
|
userid = str(ctx.user.id)
|
||||||
|
# Get all domains for user
|
||||||
|
domains = []
|
||||||
|
with open("/mnt/sslnotify.txt", "r") as file:
|
||||||
|
lines = file.readlines()
|
||||||
|
for line in lines:
|
||||||
|
line = line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
if line.startswith(userid):
|
||||||
|
_, dom = line.split(",")
|
||||||
|
domains.append(dom)
|
||||||
|
if not domains:
|
||||||
|
await ctx.response.send_message("You have no domains in the SSL expiry notification list",ephemeral=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
if domain not in domains:
|
||||||
|
await ctx.response.send_message("Domain not found in the SSL expiry notification list",ephemeral=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
with open("/mnt/sslnotify.txt", "w") as file:
|
||||||
|
for line in lines:
|
||||||
|
line = line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
if not line.startswith(userid):
|
||||||
|
file.write(line + "\n")
|
||||||
|
for dom in domains:
|
||||||
|
if domain != dom:
|
||||||
|
file.write(userid + "," + dom + "\n")
|
||||||
|
|
||||||
|
await ctx.response.send_message("Domain removed from the SSL expiry notification list",ephemeral=True)
|
||||||
|
|
||||||
|
|
||||||
|
@tree.command(name="manualsslcheck", description="Manually check SSL certificate")
|
||||||
|
async def manualsslcheck(ctx):
|
||||||
|
if (ctx.user.id != ADMINID):
|
||||||
|
await log("User: " + str(ctx.user.name) + " tried to use the manualsslcheck command")
|
||||||
|
await ctx.response.send_message("You don't have permission to use this command",ephemeral=True)
|
||||||
|
|
||||||
|
await ctx.response.send_message("SSL checking",ephemeral=True)
|
||||||
|
await checkForSSLExpiry()
|
||||||
|
await ctx.response.send_message("SSL check complete",ephemeral=True)
|
||||||
|
|
||||||
|
|
||||||
# When the bot is ready
|
# When the bot is ready
|
||||||
@ -403,12 +448,12 @@ async def on_ready():
|
|||||||
ADMINID = client.application.owner.id
|
ADMINID = client.application.owner.id
|
||||||
await tree.sync()
|
await tree.sync()
|
||||||
updateStatus()
|
updateStatus()
|
||||||
|
await checkForSSLExpiry()
|
||||||
|
|
||||||
client.run(TOKEN)
|
|
||||||
|
|
||||||
# Every 12 hours check for SSL expiry
|
# Every 12 hours check for SSL expiry
|
||||||
scheduler = AsyncIOScheduler()
|
scheduler = AsyncIOScheduler()
|
||||||
scheduler.add_job(checkForSSLExpiry, 'interval', hours=12)
|
scheduler.add_job(checkForSSLExpiry, 'interval', hours=12)
|
||||||
scheduler.start()
|
scheduler.start()
|
||||||
|
|
||||||
checkForSSLExpiry()
|
client.run(TOKEN)
|
Loading…
Reference in New Issue
Block a user