2022-06-10 09:47:41 +00:00
|
|
|
import time
|
2022-11-15 09:19:08 +00:00
|
|
|
|
|
|
|
from flask import g
|
|
|
|
|
2022-06-10 09:47:41 +00:00
|
|
|
from files.classes.user import User
|
2022-11-15 09:19:08 +00:00
|
|
|
from files.helpers.alerts import send_repeatable_notification
|
2022-12-11 23:44:34 +00:00
|
|
|
from files.helpers.config.const import bots, patron, SITE_NAME
|
2022-06-10 09:47:41 +00:00
|
|
|
|
|
|
|
def award_timers(v, bot=False):
|
|
|
|
now = time.time()
|
|
|
|
|
|
|
|
def notify_if_not_bot(msg):
|
|
|
|
if not bot:
|
2022-09-07 03:31:55 +00:00
|
|
|
send_repeatable_notification(v.id, msg)
|
2022-06-10 09:47:41 +00:00
|
|
|
|
|
|
|
if v.patron_utc and v.patron_utc < now:
|
|
|
|
v.patron = 0
|
|
|
|
v.patron_utc = 0
|
2022-08-14 12:59:56 +00:00
|
|
|
notify_if_not_bot(f"Your {patron} status has expired!")
|
2022-06-10 09:47:41 +00:00
|
|
|
if v.unban_utc and v.unban_utc < now:
|
2022-12-13 22:02:53 +00:00
|
|
|
v.is_banned = None
|
2022-06-10 09:47:41 +00:00
|
|
|
v.unban_utc = 0
|
2022-07-11 12:35:28 +00:00
|
|
|
v.ban_reason = None
|
2022-06-10 09:47:41 +00:00
|
|
|
notify_if_not_bot("You have been unbanned!")
|
2022-08-17 19:17:34 +00:00
|
|
|
if v.agendaposter and v.agendaposter != 1 and v.agendaposter < now:
|
2022-06-10 09:47:41 +00:00
|
|
|
v.agendaposter = 0
|
2022-11-05 01:59:53 +00:00
|
|
|
notify_if_not_bot("Your chud status has expired!")
|
2022-06-10 09:47:41 +00:00
|
|
|
badge = v.has_badge(28)
|
|
|
|
if badge: g.db.delete(badge)
|
|
|
|
if v.flairchanged and v.flairchanged < now:
|
|
|
|
v.flairchanged = None
|
|
|
|
notify_if_not_bot("Your flair lock has expired. You can now change your flair!")
|
|
|
|
badge = v.has_badge(96)
|
|
|
|
if badge: g.db.delete(badge)
|
|
|
|
if v.marseyawarded and v.marseyawarded < now:
|
|
|
|
v.marseyawarded = None
|
|
|
|
notify_if_not_bot("Your marsey award has expired!")
|
|
|
|
badge = v.has_badge(98)
|
|
|
|
if badge: g.db.delete(badge)
|
|
|
|
if v.longpost and v.longpost < now:
|
|
|
|
v.longpost = None
|
|
|
|
notify_if_not_bot("Your pizzashill award has expired!")
|
|
|
|
badge = v.has_badge(97)
|
|
|
|
if badge: g.db.delete(badge)
|
|
|
|
if v.bird and v.bird < now:
|
|
|
|
v.bird = None
|
|
|
|
notify_if_not_bot("Your bird site award has expired!")
|
|
|
|
badge = v.has_badge(95)
|
|
|
|
if badge: g.db.delete(badge)
|
2022-12-04 19:30:33 +00:00
|
|
|
if v.progressivestack and v.progressivestack != 1 and v.progressivestack < now:
|
2022-06-10 09:47:41 +00:00
|
|
|
v.progressivestack = None
|
|
|
|
notify_if_not_bot("Your progressive stack has expired!")
|
|
|
|
badge = v.has_badge(94)
|
|
|
|
if badge: g.db.delete(badge)
|
|
|
|
if v.rehab and v.rehab < now:
|
|
|
|
v.rehab = None
|
|
|
|
notify_if_not_bot("Your rehab has finished!")
|
|
|
|
badge = v.has_badge(109)
|
|
|
|
if badge: g.db.delete(badge)
|
|
|
|
if v.deflector and v.deflector < now:
|
|
|
|
v.deflector = None
|
|
|
|
notify_if_not_bot("Your deflector has expired!")
|
2022-09-07 03:31:55 +00:00
|
|
|
if v.owoify and v.owoify < now:
|
|
|
|
v.owoify = None
|
|
|
|
notify_if_not_bot("Your OwOify status has expired!")
|
|
|
|
badge = v.has_badge(167)
|
2022-08-27 02:57:19 +00:00
|
|
|
if v.bite and v.bite < now:
|
|
|
|
v.bite = None
|
2022-09-17 12:15:22 +00:00
|
|
|
notify_if_not_bot("Your vampire status has ended!")
|
|
|
|
v.house = v.old_house
|
|
|
|
v.old_house = ''
|
2022-09-07 03:31:55 +00:00
|
|
|
badge = v.has_badge(168)
|
|
|
|
if badge: g.db.delete(badge)
|
2022-08-27 02:57:19 +00:00
|
|
|
if v.earlylife and v.earlylife < now:
|
|
|
|
v.earlylife = None
|
|
|
|
notify_if_not_bot("Your earlylife status has expired!")
|
2022-09-07 03:31:55 +00:00
|
|
|
badge = v.has_badge(169)
|
2022-09-30 23:20:53 +00:00
|
|
|
if badge: g.db.delete(badge)
|
2022-12-04 19:30:33 +00:00
|
|
|
if v.marsify and v.marsify != 1 and v.marsify < now:
|
2022-09-05 04:50:27 +00:00
|
|
|
v.marsify = 0
|
2022-09-02 18:10:35 +00:00
|
|
|
if SITE_NAME != 'rDrama': notify_if_not_bot("Your marsify status has expired!")
|
2022-09-07 03:31:55 +00:00
|
|
|
badge = v.has_badge(170)
|
|
|
|
if badge: g.db.delete(badge)
|
|
|
|
if v.rainbow and v.rainbow < now:
|
|
|
|
v.rainbow = None
|
|
|
|
notify_if_not_bot("Your rainbow has expired!")
|
|
|
|
badge = v.has_badge(171)
|
2022-09-23 13:15:56 +00:00
|
|
|
if badge: g.db.delete(badge)
|
2022-09-24 00:02:27 +00:00
|
|
|
if v.spider and v.spider != 1 and v.spider < now:
|
2022-09-29 10:21:55 +00:00
|
|
|
v.spider = 0
|
2022-09-23 13:15:56 +00:00
|
|
|
notify_if_not_bot("Your spider friend has left you!")
|
|
|
|
badge = v.has_badge(179)
|
|
|
|
if badge: g.db.delete(badge)
|
2022-09-07 03:31:55 +00:00
|
|
|
|
|
|
|
g.db.add(v)
|
2022-06-10 09:47:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
def award_timers_bots_task():
|
|
|
|
accs = g.db.query(User).filter(User.id.in_(bots))
|
|
|
|
for u in accs:
|
|
|
|
award_timers(u, bot=True)
|