master
Aevann1 2022-05-28 04:20:31 +02:00
parent c033f6177f
commit cd2380fb33
5 changed files with 19 additions and 22 deletions

View File

@ -20,6 +20,8 @@ def create_comment(text_html, autojanny=False):
def send_repeatable_notification(uid, text, autojanny=False):
if uid in bots: return
if autojanny: author_id = AUTOJANNY_ID
else: author_id = NOTIFICATIONS_ID
@ -39,6 +41,7 @@ def send_repeatable_notification(uid, text, autojanny=False):
def send_notification(uid, text, autojanny=False):
if uid in bots: return
cid = notif_comment(text, autojanny)
add_notif(cid, uid)
@ -87,6 +90,8 @@ def notif_comment2(p):
def add_notif(cid, uid):
if uid in bots: return
existing = g.db.query(Notification.user_id).filter_by(comment_id=cid, user_id=uid).one_or_none()
if not existing:
notif = Notification(comment_id=cid, user_id=uid)
@ -109,4 +114,4 @@ def NOTIFY_USERS(text, v):
user = get_user(i.group(2), graceful=True)
if user and v.id != user.id and not v.any_block_exists(user): notify_users.add(user.id)
return notify_users
return notify_users - bots

View File

@ -321,6 +321,9 @@ else:
WELCOME_MSG = f"Welcome to {SITE_NAME}!"
ROLES={}
bots = {NOTIFICATIONS_ID, AUTOJANNY_ID, SNAPPY_ID, LONGPOSTBOT_ID, ZOZBOT_ID, AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID, BASEDBOT_ID}
IMGUR_KEY = environ.get("IMGUR_KEY").strip()
PUSHER_ID = environ.get("PUSHER_ID", "").strip()
PUSHER_KEY = environ.get("PUSHER_KEY", "").strip()

View File

@ -613,10 +613,10 @@ def api_comment(v):
for x in g.db.query(Subscription.user_id).filter_by(submission_id=c.parent_submission).all(): notify_users.add(x[0])
if parent.author.id not in (v.id, BASEDBOT_ID, AUTOJANNY_ID, SNAPPY_ID, LONGPOSTBOT_ID, ZOZBOT_ID, AUTOPOLLER_ID, AUTOCHOICE_ID):
if parent.author.id != v.id:
notify_users.add(parent.author.id)
for x in notify_users:
for x in notify_users-bots:
n = Notification(comment_id=c.id, user_id=x)
g.db.add(n)
@ -835,7 +835,7 @@ def edit_comment(cid, v):
notify_users = NOTIFY_USERS(body, v)
for x in notify_users:
for x in notify_users-bots:
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=x).one_or_none()
if not notif:
n = Notification(comment_id=c.id, user_id=x)

View File

@ -140,8 +140,7 @@ def stats(site=None):
stats.update(stats2)
ids = (NOTIFICATIONS_ID, AUTOJANNY_ID, SNAPPY_ID, LONGPOSTBOT_ID, ZOZBOT_ID)
bots = g.db.query(User).filter(User.id.in_(ids))
bots = g.db.query(User).filter(User.id.in_(bots))
for u in bots:
g.db.add(u)
@ -149,60 +148,49 @@ def stats(site=None):
if u.patron_utc and u.patron_utc < time.time():
u.patron = 0
u.patron_utc = 0
send_repeatable_notification(u.id, "Your paypig status has expired!")
if u.discord_id: remove_role(v, "1")
if u.unban_utc and u.unban_utc < time.time():
u.is_banned = 0
u.unban_utc = 0
u.ban_evade = 0
send_repeatable_notification(u.id, "You have been unbanned!")
if u.agendaposter and u.agendaposter < time.time():
u.agendaposter = 0
send_repeatable_notification(u.id, "Your chud theme has expired!")
badge = u.has_badge(28)
if badge: g.db.delete(badge)
if u.flairchanged and u.flairchanged < time.time():
u.flairchanged = None
send_repeatable_notification(u.id, "Your flair lock has expired. You can now change your flair!")
badge = u.has_badge(96)
if badge: g.db.delete(badge)
if u.marseyawarded and u.marseyawarded < time.time():
u.marseyawarded = None
send_repeatable_notification(u.id, "Your marsey award has expired!")
badge = u.has_badge(98)
if badge: g.db.delete(badge)
if u.longpost and u.longpost < time.time():
u.longpost = None
send_repeatable_notification(u.id, "Your pizzashill award has expired!")
badge = u.has_badge(97)
if badge: g.db.delete(badge)
if u.bird and u.bird < time.time():
u.bird = None
send_repeatable_notification(u.id, "Your bird site award has expired!")
badge = u.has_badge(95)
if badge: g.db.delete(badge)
if u.progressivestack and u.progressivestack < time.time():
u.progressivestack = None
send_repeatable_notification(u.id, "Your progressive stack has expired!")
badge = u.has_badge(94)
if badge: g.db.delete(badge)
if u.rehab and u.rehab < time.time():
u.rehab = None
send_repeatable_notification(u.id, "Your rehab has finished!")
badge = u.has_badge(109)
if badge: g.db.delete(badge)
if u.deflector and u.deflector < time.time():
u.deflector = None
send_repeatable_notification(u.id, "Your deflector has expired!")
g.db.commit()

View File

@ -667,10 +667,11 @@ def message2(v, username):
c.top_comment_id = c.id
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=user.id).one_or_none()
if not notif:
notif = Notification(comment_id=c.id, user_id=user.id)
g.db.add(notif)
if user.id not in bots:
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=user.id).one_or_none()
if not notif:
notif = Notification(comment_id=c.id, user_id=user.id)
g.db.add(notif)
g.db.commit()
@ -741,7 +742,7 @@ def messagereply(v):
g.db.add(notif)
g.db.flush()
if user_id and user_id != v.id and user_id != 2:
if user_id and user_id not in (v.id, 2, bots):
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=user_id).one_or_none()
if not notif:
notif = Notification(comment_id=c.id, user_id=user_id)