Queer European MD passionate about IT
Ver código fonte

Replace longer strings first

Davte 4 anos atrás
pai
commit
f29556300a
2 arquivos alterados com 3 adições e 2 exclusões
  1. 1 1
      davtelepot/__init__.py
  2. 2 1
      davtelepot/utilities.py

+ 1 - 1
davtelepot/__init__.py

@@ -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"
 

+ 2 - 1
davtelepot/utilities.py

@@ -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)