lib/lita/handlers/markov.rb in lita-markov-1.2.0 vs lib/lita/handlers/markov.rb in lita-markov-1.2.1
- old
+ new
@@ -7,11 +7,11 @@
module Lita::Handlers
class Markov
template_root File.expand_path('../../../../templates', __FILE__)
config :database_url, type: String, required: true
-
+
route(/.+/, :ingest, command: false)
route(/markov (.+)/, :generate, command: true, help: {
'markov USER' => 'Generate a markov chain from the given user.'
})
@@ -38,11 +38,11 @@
engine.ingest id, message
end
def generate(chat)
- name = chat.matches[0][0].strip
+ name = simplify_name chat.matches[0][0]
user = Lita::User.fuzzy_find name
if user.nil?
chat.reply "Couldn't find the user #{name}. :("
return
@@ -116,9 +116,15 @@
private
def render_backlog_form(response)
response.write render_template('backlog_form')
+ end
+
+ def simplify_name name
+ name
+ .strip
+ .tr('@', '')
end
Lita.register_handler self
end
end