From 7ea49c3cc9cb9726ef70db4f4ed82ba85d22eade Mon Sep 17 00:00:00 2001 From: Aevann Date: Wed, 14 Feb 2024 19:11:41 +0200 Subject: [PATCH] fix this https://rdrama.net/notification/5408283 --- files/helpers/owoify.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/files/helpers/owoify.py b/files/helpers/owoify.py index 566ae6100..b1d75c911 100644 --- a/files/helpers/owoify.py +++ b/files/helpers/owoify.py @@ -17,9 +17,6 @@ OWO_EXCLUDE_PATTERNS = [ sanitize_url_regex, # bare links mention_regex, # mentions group_mention_regex, #ping group mentions - poll_regex, # polls - choice_regex, - bet_regex, command_regex, # markup commands ] @@ -33,16 +30,21 @@ def owoify(source, chud_phrase): words = [Word(s) for s in word_matches] spaces = [Word(s) for s in space_matches] - chud_words = chud_phrase.split() if chud_phrase else [] + ignored_words = chud_phrase.split() if chud_phrase else [] - words = list(map(lambda w: owoify_map_token_custom(w, chud_words), words)) + for pattern in (poll_regex, choice_regex, bet_regex): + matches = [x.group(0) for x in pattern.finditer(source.lower())] + for match in matches: + ignored_words += match.split() + + words = list(map(lambda w: owoify_map_token_custom(w, ignored_words), words)) result = interleave_arrays(words, spaces) result_strings = list(map(lambda w: str(w), result)) return ''.join(result_strings) -def owoify_map_token_custom(token, chud_words): - if token.word.lower() in chud_words: +def owoify_map_token_custom(token, ignored_words): + if token.word.lower() in ignored_words: return token for pattern in OWO_EXCLUDE_PATTERNS: