Class: Numbr5::Bot

Inherits:
EventMachine::Connection
  • Object
show all
Includes:
EventMachine::Protocols::LineText2
Defined in:
lib/numbr5/bot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel) ⇒ Bot

Returns a new instance of Bot.



7
8
9
# File 'lib/numbr5/bot.rb', line 7

def initialize(channel)
  @channel = channel
end

Instance Attribute Details

#channelObject (readonly)

Returns the value of attribute channel.



5
6
7
# File 'lib/numbr5/bot.rb', line 5

def channel
  @channel
end

Instance Method Details

#receive_data(data) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/numbr5/bot.rb', line 11

def receive_data(data)
  case data
  when /no ident/i
    identify_and_join
  when /^PING /
    pong data.gsub(/^PING /i, '')
  when / PRIVMSG numbr5 /
    match = data.match(/:([^!]+).+ PRIVMSG numbr5 :(.+)/)
    private_message match[1], match[2]
  when / PRIVMSG ##{channel}/
    match = data.match(/:([^!]+).+ PRIVMSG ##{channel} :(.+)$/)
    public_message match[1], match[2]
  end
end