Fix backronym crashes

This commit is contained in:
minerobber 2018-12-23 19:59:49 +00:00
parent fad0da2ff9
commit 1a44d05a21
1 changed files with 5 additions and 1 deletions

View File

@ -6,7 +6,11 @@ words.loadDict("words")
def backronym(bot,channel,nick,word):
result = []
for char in word:
result.append(random.choice(words.getWords("^{}.*".format(char))))
fwords = words.getWords("^{}.*".format(char))
if not fwords:
bot.say(channel,nick+": Don't be a meanie! (No words start with '{}'!)".format(char))
else:
result.append(random.choice(fwords))
bot.say(channel,nick+": "+titlecase(" ".join(result)))
@plugin.command("kwam","")