Class: Ruboty::Handlers::LastWords

Inherits:
Base
  • Object
show all
Defined in:
lib/ruboty/handlers/last_words.rb

Instance Method Summary collapse

Instance Method Details

#catchall(message) ⇒ Object



7
8
9
# File 'lib/ruboty/handlers/last_words.rb', line 7

def catchall(message)
  words[message.from_name] = { body: message[:keyword], time: Time.new }
end

#last_words(message) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/ruboty/handlers/last_words.rb', line 11

def last_words(message)
  if last_words = words[message[:username]]
    header = "#{message[:username]} said..."
    body = "#{last_words[:body]}\n[#{last_words[:time]}]"
    message.reply(header)
    message.reply(body, code: true)
  else
    message.reply("#{message[:username]} was forgotten...")
  end
end