From d020b993598aa69626d2910e73a02b2a3c778bac Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 26 Feb 2023 00:06:49 +0200 Subject: [PATCH] link to ping groups --- files/helpers/sanitize.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 9a0e252dd..f2c817cc7 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -12,9 +12,11 @@ from bleach.css_sanitizer import CSSSanitizer from bleach.linkifier import LinkifyFilter from bs4 import BeautifulSoup from mistletoe import markdown + from files.classes.domains import BannedDomain from files.classes.mod_logs import ModAction from files.classes.notifications import Notification +from files.classes.group import Group from files.helpers.config.const import * from files.helpers.const_stateful import * @@ -417,6 +419,13 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys sanitized = mention_regex.sub(replacer, sanitized) + if FEATURES['PING_GROUPS']: + for i in group_mention_regex.finditer(sanitized): + name = i.group(2) + existing = g.db.get(Group, name) + if existing: + sanitized = sanitized.replace(f'!{name}', f'!{name}') + soup = BeautifulSoup(sanitized, 'lxml') for tag in soup.find_all("img"):