.BANCHO. Add notification when donor tag is expiring soon

This commit is contained in:
Nyo
2016-09-25 19:05:31 +02:00
parent 4b6e621a70
commit 121d19aaa7
2 changed files with 22 additions and 1 deletions

View File

@@ -626,4 +626,15 @@ def cacheUserIDs():
"""Cache userIDs in glob.userIDCache, used later with getID()."""
data = glob.db.fetchAll("SELECT id, username FROM users WHERE privileges & {} > 0".format(privileges.USER_NORMAL))
for i in data:
glob.userIDCache[i["username"]] = i["id"]
glob.userIDCache[i["username"]] = i["id"]
def getDonorExpire(userID):
"""
Return userID's donor expiration UNIX timestamp
:param userID:
:return: donor expiration UNIX timestamp
"""
data = glob.db.fetch("SELECT donor_expire FROM users WHERE id = %s LIMIT 1", [userID])
if data is not None:
return data["donor_expire"]
return 0