1
0
mirror of https://github.com/MrDetonia/Maki.git synced 2024-11-22 20:00:00 -05:00

Fixed KeyError when invalid username used with .markov, v0.10.6

This commit is contained in:
Zac Herd 2016-04-04 10:07:24 +01:00
parent 98b2076730
commit 20c838df9e

4
bot.py
View File

@ -25,7 +25,7 @@ from secret import email,pwd
name = "Maki" name = "Maki"
# bot version # bot version
version = "v0.10.5" version = "v0.10.6"
# text shown by .help command # text shown by .help command
helptext = """I am a bot written in Python by MrDetonia helptext = """I am a bot written in Python by MrDetonia
@ -267,7 +267,7 @@ def on_message(message):
elif message.content.startswith('.markov'): elif message.content.startswith('.markov'):
# generate a markov chain sentence based on the user's chat history # generate a markov chain sentence based on the user's chat history
tmp = message.content[8:] tmp = message.content[8:]
if os.path.isfile('./markovs/' + users[tmp]): if tmp in users and os.path.isfile('./markovs/' + users[tmp]):
mc = markov.Markov(open('./markovs/' + users[tmp])) mc = markov.Markov(open('./markovs/' + users[tmp]))
try: try:
response = mc.generate_text(random.randint(20,40)) response = mc.generate_text(random.randint(20,40))