Class: Numbr5::Bot
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- Numbr5::Bot
- Includes:
- EventMachine::Protocols::LineText2
- Defined in:
- lib/numbr5/bot.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
Instance Method Summary collapse
-
#initialize(channel) ⇒ Bot
constructor
A new instance of Bot.
- #receive_data(data) ⇒ Object
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
#channel ⇒ Object (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 :(.+)/) match[1], match[2] when / PRIVMSG ##{channel}/ match = data.match(/:([^!]+).+ PRIVMSG ##{channel} :(.+)$/) match[1], match[2] end end |