Class: ModSpox::Handlers::Privmsg
- Defined in:
- lib/mod_spox/handlers/Privmsg.rb
Instance Method Summary collapse
-
#initialize(handlers) ⇒ Privmsg
constructor
A new instance of Privmsg.
- #process(string) ⇒ Object
Constructor Details
#initialize(handlers) ⇒ Privmsg
Returns a new instance of Privmsg.
5 6 7 |
# File 'lib/mod_spox/handlers/Privmsg.rb', line 5 def initialize(handlers) handlers[:PRIVMSG] = self end |
Instance Method Details
#process(string) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mod_spox/handlers/Privmsg.rb', line 9 def process(string) if(string =~ /^:(\S+)\sPRIVMSG\s(\S+)\s:(.+)$/) = $3 target = find_model($2) base_source = $1 source = find_model(base_source.gsub(/!.+$/, '')) if(base_source =~ /!(.+)@(.+)$/) source.username == $1 source.address = $2 source.source = base_source source.save_changes end Models::NickChannel.find_or_create(:channel_id => target.pk, :nick_id => source.pk) if target.is_a?(ModSpox::Models::Channel) return Messages::Incoming::Privmsg.new(string, source, target, ) else Logger.log('Failed to match PRIVMSG message') return nil end end |