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

@ -14,7 +14,7 @@ __author__ = "Davide Testa"
__email__ = "davide@davte.it"
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
__license__ = "GNU General Public License v3.0"
__version__ = "2.4.16"
__version__ = "2.4.17"
__maintainer__ = "Davide Testa"
__contact__ = "t.me/davte"

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)