lib/lita/handlers/markov.rb in lita-markov-1.0.1 vs lib/lita/handlers/markov.rb in lita-markov-1.0.2

- old
+ new

@@ -29,13 +29,18 @@ engine.ingest id, message end def generate(chat) name = chat.matches[0][0].strip - id = Lita::User.fuzzy_find(name).id + user = Lita::User.fuzzy_find name + if user.nil? + chat.reply "Couldn't find the user #{name}. :(" + return + end + begin - sentence = engine.generate_sentence_for id + sentence = engine.generate_sentence_for user.id chat.reply sentence rescue Engine::EmptyDictionaryError chat.reply "Looks like #{name} hasn't said anything!" end