diff --git a/utils.py b/utils.py index 685185f..7e17610 100644 --- a/utils.py +++ b/utils.py @@ -44,10 +44,13 @@ def remove_notifications(text): "soren", ] + def replace(match): + # Insert after the first character of the matched string. + user = match.group() + return f"{user[:1]}{user[1:]}" + for user in notified_users: - match = re.search(user, text, re.IGNORECASE) - if match: - text = f"{text[:match.start() + 1]}{text[match.start() + 1:]}" + text = re.sub(user, replace, text, flags=re.IGNORECASE) return text