bot: Add check for expiry past
All checks were successful
Build Docker / Build Docker (push) Successful in 17s

This commit is contained in:
Nathan Woodburn 2023-10-01 13:20:04 +11:00
parent af3f2c49d2
commit 2f0ec449c8
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

10
bot.py
View File

@ -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: