forked from rDrama/rDrama
fix repeated group pings
parent
92bf3f7134
commit
b6d4ecfb40
|
@ -377,14 +377,18 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_emojis=
|
||||||
sanitized = mention_regex.sub(replacer, sanitized)
|
sanitized = mention_regex.sub(replacer, sanitized)
|
||||||
|
|
||||||
if FEATURES['PING_GROUPS']:
|
if FEATURES['PING_GROUPS']:
|
||||||
for i in group_mention_regex.finditer(sanitized):
|
def group_replacer(m):
|
||||||
name = i.group(1).lower()
|
name = m.group(1).lower()
|
||||||
|
|
||||||
if name == 'everyone':
|
if name == 'everyone':
|
||||||
sanitized = group_mention_regex.sub(r'<a href="/users">!\1</a>', sanitized)
|
return f'<a href="/users">!{name}</a>'
|
||||||
|
elif g.db.get(Group, name):
|
||||||
|
return f'<a href="/!{name}">!{name}</a>'
|
||||||
else:
|
else:
|
||||||
existing = g.db.get(Group, name)
|
return m.group(0)
|
||||||
if existing:
|
|
||||||
sanitized = sanitized.replace(i.group(0), f'<a href="/!{name}">!{name}</a>', 1)
|
sanitized = group_mention_regex.sub(group_replacer, sanitized)
|
||||||
|
|
||||||
|
|
||||||
soup = BeautifulSoup(sanitized, 'lxml')
|
soup = BeautifulSoup(sanitized, 'lxml')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue