Class: ModSpox::Handlers::Topic
- Defined in:
- lib/mod_spox/handlers/Topic.rb
Instance Method Summary collapse
-
#initialize(handlers) ⇒ Topic
constructor
A new instance of Topic.
-
#process(string) ⇒ Object
:irc.host 332 spox #mod_spox : the topic is here :irc.host 333 spox #mod_spox spox 1232126516.
Methods inherited from Handler
Constructor Details
#initialize(handlers) ⇒ Topic
Returns a new instance of Topic.
5 6 7 8 9 10 |
# File 'lib/mod_spox/handlers/Topic.rb', line 5 def initialize(handlers) handlers[RPL_TOPIC] = self handlers[RPL_NOTOPIC] = self handlers[RPL_TOPICINFO] = self @topics = Hash.new end |
Instance Method Details
#process(string) ⇒ Object
:irc.host 332 spox #mod_spox : the topic is here :irc.host 333 spox #mod_spox spox 1232126516
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mod_spox/handlers/Topic.rb', line 15 def process(string) if(string =~ /#{RPL_TOPIC}.+?(\S+)\s:(.+)$/) channel = find_model($1) channel.update(:topic => $2) return Messages::Incoming::Topic.new(string, channel, $2) elsif(string =~ /#{RPL_NOTOPIC}.+?(\S+)\s:/) channel = find_model($1) return Messages::Incoming::Topic.new(string, channel, nil) elsif(string =~ /#{RPL_TOPICINFO}\s\S+\s(\S+)\s(\S+)\s(.+)$/) channel = find_model($1) nick = find_model($1) time = Time.at($3.to_i) return Messages::Incoming::TopicInfo.new(string, channel, nick, time) else Logger.warn('Failed to parse TOPIC type string') return nil end end |