bot: Async the ssl check function
All checks were successful
Build Docker / Build Docker (push) Successful in 16s

This commit is contained in:
Nathan Woodburn 2023-10-01 22:53:54 +11:00
parent de5c8787ba
commit 0ac3b1592b
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

6
bot.py
View File

@ -316,7 +316,7 @@ def updateStatus():
activity=discord.Activity(type=discord.ActivityType.watching, name=activityMessage)
client.loop.create_task(client.change_presence(activity=activity))
def checkForSSLExpiry():
async def checkForSSLExpiry():
with open("/mnt/sslnotify.txt", "r") as file:
lines = file.readlines()
for line in lines:
@ -358,12 +358,12 @@ def checkForSSLExpiry():
if expiry_date < datetime.datetime.now() + datetime.timedelta(days=7):
user = client.get_user(int(userid))
if user:
user.send(f"SSL certificate for {domain} expires soon")
await user.send(f"SSL certificate for {domain} expires soon")
else:
# Test by sending a message
user = client.get_user(int(userid))
if user:
user.send(f"SSL certificate for {domain} is valid")
await user.send(f"SSL certificate for {domain} is valid")
except Exception as e:
print(e, flush=True)
continue