Fix a couple small bugs in markov bot

* .items() call required when loading a markov chain into memory
* `who.nick` instead of `who~ for get_chain call

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-05-30 17:02:09 -07:00
parent de477210b1
commit 9bed657f5f

View File

@@ -101,7 +101,7 @@ class Chain:
for word, weight in value.items() for word, weight in value.items()
}, },
) )
for key, value in obj["chain"] for key, value in obj["chain"].items()
}, },
) )
self.__dirty = False self.__dirty = False
@@ -192,7 +192,7 @@ class Markov(Plugin):
self.add(channel, who.nick, line) self.add(channel, who.nick, line)
# also, maybe generate a sentence # also, maybe generate a sentence
chosen = random.random() chosen = random.random()
chain = self.get_chain(channel, who) chain = self.get_chain(channel, who.nick)
if chosen <= chain.reply_chance: if chosen <= chain.reply_chance:
pass pass