diff --git a/files/helpers/const.py b/files/helpers/const.py index 94321e6c5..70d28972b 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -701,6 +701,8 @@ sub_regex = re.compile('(^|\s|

)\/?(h\/(\w|-){3,25})', flags=re.A) youtube_regex = re.compile('" target="_blank">(https://youtube\.com/watch\?v\=(.*?))(?!)', flags=re.A) strikethrough_regex = re.compile('~{1,2}([^~]+)~{1,2}', flags=re.A) +mute_regex = re.compile("/mute @([a-z0-9_\-]{3,25}) ([0-9])+", flags=re.A) + emoji_regex = re.compile("[^a]>\s*(:[!#]{0,2}\w+:\s*)+<\/", flags=re.A) emoji_regex2 = re.compile('(? muted[vname]: return '', 403 + else: del muted[vname] + global messages, total text = data[:1000].strip() if not text: return '', 403 @@ -55,6 +62,14 @@ def speak(data, v): messages = messages[-50:] total += 1 emit('speak', data, broadcast=True) + + if v.admin_level > 1: + text = text.lower() + for i in mute_regex.finditer(text): + username = i.group(1) + duration = int(int(i.group(2)) * 60 + time.time()) + muted[username] = duration + return '', 204 @socketio.on('connect') @@ -92,4 +107,5 @@ def typing_indicator(data, v): def close_running_threads(): cache.set('chat', messages) cache.set('total', total) + cache.set('muted', muted) atexit.register(close_running_threads) \ No newline at end of file