From 2f0ec449c8235bf9dd3aac39b5d9aad985d423d2 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Sun, 1 Oct 2023 13:20:04 +1100 Subject: [PATCH] bot: Add check for expiry past --- bot.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 0b42109..c287864 100644 --- a/bot.py +++ b/bot.py @@ -224,7 +224,15 @@ async def ssl(ctx, domain: str): domain_check = True expiry_date = cert_obj.not_valid_after - message = message + "\n## Certificate Expiry:\n" + str(expiry_date) + "\n" + # Check if expiry date is past + if expiry_date < datetime.datetime.now(): + message = message + "\n## Expiry Date:\n:x: Certificate has expired\n" + elif expiry_date < datetime.datetime.now() + datetime.timedelta(days=7): + message = message + "\n## Expiry Date:\n:warning: Certificate expires soon\n" + else: + message = message + "\n## Expiry Date:\n:white_check_mark: Certificate is valid\n" + + message = message + expiry_date.strftime("%d %B %Y %H:%M:%S") + "\n" else: