Optimize sanitation

This commit is contained in:
Klaus-Uwe Mitterer 2017-02-27 12:03:58 +01:00
parent fed45e7b9b
commit 534b3ddda7

View file

@ -19,7 +19,7 @@ def sanitizeText(text):
if text[0] == "@" or text[1] == "@":
if split[1][0] not in string.ascii_lowercase:
return sanitizeText(" ".join(split[1:]))
if split[-1][0] == "@":
if split[-1][0] == "@" and text[-1] in string.ascii_lowercase:
return sanitizeText(" ".join(split[:-1]))
if text[:4] == "RT @":
return sanitizeText(text.partition(":")[2])