forked from rDrama/rDrama
fds
parent
c033f6177f
commit
cd2380fb33
|
@ -20,6 +20,8 @@ def create_comment(text_html, autojanny=False):
|
||||||
|
|
||||||
def send_repeatable_notification(uid, text, autojanny=False):
|
def send_repeatable_notification(uid, text, autojanny=False):
|
||||||
|
|
||||||
|
if uid in bots: return
|
||||||
|
|
||||||
if autojanny: author_id = AUTOJANNY_ID
|
if autojanny: author_id = AUTOJANNY_ID
|
||||||
else: author_id = NOTIFICATIONS_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):
|
def send_notification(uid, text, autojanny=False):
|
||||||
|
|
||||||
|
if uid in bots: return
|
||||||
cid = notif_comment(text, autojanny)
|
cid = notif_comment(text, autojanny)
|
||||||
add_notif(cid, uid)
|
add_notif(cid, uid)
|
||||||
|
|
||||||
|
@ -87,6 +90,8 @@ def notif_comment2(p):
|
||||||
|
|
||||||
|
|
||||||
def add_notif(cid, uid):
|
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()
|
existing = g.db.query(Notification.user_id).filter_by(comment_id=cid, user_id=uid).one_or_none()
|
||||||
if not existing:
|
if not existing:
|
||||||
notif = Notification(comment_id=cid, user_id=uid)
|
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)
|
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)
|
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
|
|
@ -321,6 +321,9 @@ else:
|
||||||
WELCOME_MSG = f"Welcome to {SITE_NAME}!"
|
WELCOME_MSG = f"Welcome to {SITE_NAME}!"
|
||||||
ROLES={}
|
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()
|
IMGUR_KEY = environ.get("IMGUR_KEY").strip()
|
||||||
PUSHER_ID = environ.get("PUSHER_ID", "").strip()
|
PUSHER_ID = environ.get("PUSHER_ID", "").strip()
|
||||||
PUSHER_KEY = environ.get("PUSHER_KEY", "").strip()
|
PUSHER_KEY = environ.get("PUSHER_KEY", "").strip()
|
||||||
|
|
|
@ -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])
|
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)
|
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)
|
n = Notification(comment_id=c.id, user_id=x)
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
|
|
||||||
|
@ -835,7 +835,7 @@ def edit_comment(cid, v):
|
||||||
|
|
||||||
notify_users = NOTIFY_USERS(body, 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()
|
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=x).one_or_none()
|
||||||
if not notif:
|
if not notif:
|
||||||
n = Notification(comment_id=c.id, user_id=x)
|
n = Notification(comment_id=c.id, user_id=x)
|
||||||
|
|
|
@ -140,8 +140,7 @@ def stats(site=None):
|
||||||
|
|
||||||
stats.update(stats2)
|
stats.update(stats2)
|
||||||
|
|
||||||
ids = (NOTIFICATIONS_ID, AUTOJANNY_ID, SNAPPY_ID, LONGPOSTBOT_ID, ZOZBOT_ID)
|
bots = g.db.query(User).filter(User.id.in_(bots))
|
||||||
bots = g.db.query(User).filter(User.id.in_(ids))
|
|
||||||
|
|
||||||
for u in bots:
|
for u in bots:
|
||||||
g.db.add(u)
|
g.db.add(u)
|
||||||
|
@ -149,60 +148,49 @@ def stats(site=None):
|
||||||
if u.patron_utc and u.patron_utc < time.time():
|
if u.patron_utc and u.patron_utc < time.time():
|
||||||
u.patron = 0
|
u.patron = 0
|
||||||
u.patron_utc = 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():
|
if u.unban_utc and u.unban_utc < time.time():
|
||||||
u.is_banned = 0
|
u.is_banned = 0
|
||||||
u.unban_utc = 0
|
u.unban_utc = 0
|
||||||
u.ban_evade = 0
|
u.ban_evade = 0
|
||||||
send_repeatable_notification(u.id, "You have been unbanned!")
|
|
||||||
|
|
||||||
if u.agendaposter and u.agendaposter < time.time():
|
if u.agendaposter and u.agendaposter < time.time():
|
||||||
u.agendaposter = 0
|
u.agendaposter = 0
|
||||||
send_repeatable_notification(u.id, "Your chud theme has expired!")
|
|
||||||
badge = u.has_badge(28)
|
badge = u.has_badge(28)
|
||||||
if badge: g.db.delete(badge)
|
if badge: g.db.delete(badge)
|
||||||
|
|
||||||
if u.flairchanged and u.flairchanged < time.time():
|
if u.flairchanged and u.flairchanged < time.time():
|
||||||
u.flairchanged = None
|
u.flairchanged = None
|
||||||
send_repeatable_notification(u.id, "Your flair lock has expired. You can now change your flair!")
|
|
||||||
badge = u.has_badge(96)
|
badge = u.has_badge(96)
|
||||||
if badge: g.db.delete(badge)
|
if badge: g.db.delete(badge)
|
||||||
|
|
||||||
if u.marseyawarded and u.marseyawarded < time.time():
|
if u.marseyawarded and u.marseyawarded < time.time():
|
||||||
u.marseyawarded = None
|
u.marseyawarded = None
|
||||||
send_repeatable_notification(u.id, "Your marsey award has expired!")
|
|
||||||
badge = u.has_badge(98)
|
badge = u.has_badge(98)
|
||||||
if badge: g.db.delete(badge)
|
if badge: g.db.delete(badge)
|
||||||
|
|
||||||
if u.longpost and u.longpost < time.time():
|
if u.longpost and u.longpost < time.time():
|
||||||
u.longpost = None
|
u.longpost = None
|
||||||
send_repeatable_notification(u.id, "Your pizzashill award has expired!")
|
|
||||||
badge = u.has_badge(97)
|
badge = u.has_badge(97)
|
||||||
if badge: g.db.delete(badge)
|
if badge: g.db.delete(badge)
|
||||||
|
|
||||||
if u.bird and u.bird < time.time():
|
if u.bird and u.bird < time.time():
|
||||||
u.bird = None
|
u.bird = None
|
||||||
send_repeatable_notification(u.id, "Your bird site award has expired!")
|
|
||||||
badge = u.has_badge(95)
|
badge = u.has_badge(95)
|
||||||
if badge: g.db.delete(badge)
|
if badge: g.db.delete(badge)
|
||||||
|
|
||||||
if u.progressivestack and u.progressivestack < time.time():
|
if u.progressivestack and u.progressivestack < time.time():
|
||||||
u.progressivestack = None
|
u.progressivestack = None
|
||||||
send_repeatable_notification(u.id, "Your progressive stack has expired!")
|
|
||||||
badge = u.has_badge(94)
|
badge = u.has_badge(94)
|
||||||
if badge: g.db.delete(badge)
|
if badge: g.db.delete(badge)
|
||||||
|
|
||||||
if u.rehab and u.rehab < time.time():
|
if u.rehab and u.rehab < time.time():
|
||||||
u.rehab = None
|
u.rehab = None
|
||||||
send_repeatable_notification(u.id, "Your rehab has finished!")
|
|
||||||
badge = u.has_badge(109)
|
badge = u.has_badge(109)
|
||||||
if badge: g.db.delete(badge)
|
if badge: g.db.delete(badge)
|
||||||
|
|
||||||
if u.deflector and u.deflector < time.time():
|
if u.deflector and u.deflector < time.time():
|
||||||
u.deflector = None
|
u.deflector = None
|
||||||
send_repeatable_notification(u.id, "Your deflector has expired!")
|
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
|
|
|
@ -667,10 +667,11 @@ def message2(v, username):
|
||||||
|
|
||||||
c.top_comment_id = c.id
|
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 user.id not in bots:
|
||||||
if not notif:
|
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=user.id).one_or_none()
|
||||||
notif = Notification(comment_id=c.id, user_id=user.id)
|
if not notif:
|
||||||
g.db.add(notif)
|
notif = Notification(comment_id=c.id, user_id=user.id)
|
||||||
|
g.db.add(notif)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
|
@ -741,7 +742,7 @@ def messagereply(v):
|
||||||
g.db.add(notif)
|
g.db.add(notif)
|
||||||
g.db.flush()
|
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()
|
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=user_id).one_or_none()
|
||||||
if not notif:
|
if not notif:
|
||||||
notif = Notification(comment_id=c.id, user_id=user_id)
|
notif = Notification(comment_id=c.id, user_id=user_id)
|
||||||
|
|
Loading…
Reference in New Issue