From 0ac3b1592bdb1e58ea45ca04c3c2cd536777af81 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Sun, 1 Oct 2023 22:53:54 +1100 Subject: [PATCH] bot: Async the ssl check function --- bot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 814ad85..128f51f 100644 --- a/bot.py +++ b/bot.py @@ -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