Aevann 2023-11-04 23:28:44 +02:00
parent 0a4d315017
commit a19ea08222
5 changed files with 28 additions and 2 deletions

View File

@ -8,7 +8,7 @@ import time
from sqlalchemy.sql import text
from sqlalchemy.orm import load_only
from files.classes import Comment, Notification, PushSubscription, Group
from files.classes import Comment, Notification, PushSubscription, Group, Mod
from .config.const import *
from .regex import *
@ -183,6 +183,11 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, obj=None, followers_ping=Tr
elif i.group(1) == 'jannies':
group = None
member_ids = set(x[0] for x in g.db.query(User.id).filter(User.admin_level > 0, User.id != AEVANN_ID))
elif i.group(1) == 'holejannies':
if not get_obj_hole(obj):
abort(403, "!holejannies can only be used inside holes!")
group = None
member_ids = set(x[0] for x in g.db.query(Mod.user_id).filter_by(hole=obj.hole))
elif i.group(1) == 'followers':
if not followers_ping:
abort(403, f"You can't use !followers in posts!")

View File

@ -359,3 +359,11 @@ def get_error():
def get_page():
try: return max(int(request.values.get("page", 1)), 1)
except: return 1
def get_obj_hole(obj):
if isinstance(obj, Comment):
if obj.parent_post:
obj.hole = g.db.query(Post.hole).filter_by(id=obj.parent_post).one()[0]
else:
obj.hole = None
return obj.hole

View File

@ -442,6 +442,8 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis
return f'<a href="/users">!{name}</a>'
elif name == 'jannies':
return f'<a href="/admins">!{name}</a>'
elif name == 'holejannies' and get_obj_hole(obj):
return f'<a href="/h/{obj.hole}/mods">!{name}</a>'
elif name == 'commenters' and commenters_ping_post_id:
return f'<a href="/!commenters/{commenters_ping_post_id}/{int(time.time())}">!{name}</a>'
elif name == 'followers':

View File

@ -32,7 +32,7 @@ def create_group(v):
if not hole_group_name_regex.fullmatch(name):
abort(400, "Name does not match the required format!")
if name in {'everyone', 'jannies', 'followers', 'commenters'} or g.db.get(Group, name):
if name in {'everyone', 'jannies', 'holejannies', 'followers', 'commenters'} or g.db.get(Group, name):
abort(400, "This group already exists!")
if not v.charge_account('combined', GROUP_COST)[0]:

View File

@ -309,6 +309,17 @@
<td>!jannies</td>
<td><a href="/admins" rel="nofollow">!jannies</a></td>
</tr>
{% if SITE_NAME != 'WPD' %}
<tr>
<td>Hole Mods Mention<br>
<span style="font-style: italic; font-weight: normal">
* Mentions all mods of the hole it's used inside.
</span>
</td>
<td>!holejannies</td>
<td><a href="/h/chudrama/mods" rel="nofollow">!holejannies</a></td>
</tr>
{% endif %}
<tr>
<td>Everyone Mention<br>
<span style="font-style: italic; font-weight: normal">