If censor list is empty, don't censor

This commit is contained in:
Luke Rogers 2013-08-02 00:12:48 +12:00
parent e764890636
commit 52a1e58db1

View file

@ -20,9 +20,10 @@ def censor(text):
text = text.replace('\n', '').replace('\r', '')
replacement = '[censored]'
if 'censored_strings' in bot.config:
words = map(re.escape, bot.config['censored_strings'])
regex = re.compile('(%s)' % "|".join(words))
text = regex.sub(replacement, text)
if bot.config['censored_strings']:
words = map(re.escape, bot.config['censored_strings'])
regex = re.compile('(%s)' % "|".join(words))
text = regex.sub(replacement, text)
return text