Replace longer strings first

This commit is contained in:
Davte
2020-04-07 14:55:26 +02:00
parent 87d95fbfed
commit f29556300a
2 changed files with 3 additions and 2 deletions

View File

@@ -858,7 +858,8 @@ def get_cleaned_text(update, bot=None, replace=[], strip='/ @'):
)
)
text = update['text'].strip(strip)
for s in replace:
# Replace longer strings first
for s in sorted(replace, key=len, reverse=True):
while s and text.lower().startswith(s.lower()):
text = text[len(s):]
return text.strip(strip)