This commit is contained in:
Shea Vulpes 2023-09-13 16:57:47 +02:00 committed by GitHub
commit f6f6bb39b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -2,6 +2,7 @@
import smtplib
import os
from datetime import datetime
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import COMMASPACE, formatdate
@ -31,6 +32,13 @@ while True:
else:
break
now = datetime.now().toordinal()
if r.hget('QW_TIME', username):
last_notified = int(r.hget('QW_TIME', username))
if now - last_notified == 0:
print(f"{username} notified recently, not sending notification.")
sys.exit(0)
if r.get('QW_HTML'):
try:
template = Template(r.get('QW_HTML'))
@ -83,6 +91,8 @@ except Exception as ex:
print('Failed to send quota notification: %s' % (ex))
sys.exit(1)
r.hset("QW_TIME", username, now)
try:
sys.stdout.close()
except: