Class: SpsBot

Inherits:
SPSChat
  • Object
show all
Defined in:
lib/sps_bot.rb

Instance Method Summary collapse

Constructor Details

#initialize(host: 'localhost', port: '8080', userid: 'bot') ⇒ SpsBot

Returns a new instance of SpsBot.



10
11
12
13
14
# File 'lib/sps_bot.rb', line 10

def initialize(host: 'localhost', port: '8080', userid: 'bot')
  
  super(host: host, port: port, userid: userid)
  
end

Instance Method Details

#onincoming(sender, msg) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/sps_bot.rb', line 16

def onincoming(sender, msg)

  case msg      
  when /what's the time\?/i
    self.send 'The time is ' + Time.now.strftime("%-I:%M%p")
  when /hello?/i
    self.send "hello #{sender}, how can I help you?" % sender
  else
    self.send "I'm sorry, I don't understand what you said."
  end
  
end