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
:spox!~spox@host PRIVMSG #m :foobar.
Methods inherited from Handler
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
:spox!~spox@host PRIVMSG #m :foobar
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mod_spox/handlers/Privmsg.rb', line 10 def process(string) orig = string.dup string = string.dup begin string.slice!(0) base_source = string.slice!(0..string.index(' ')-1) orig_source = base_source.dup string.slice!(0..string.index(' ',3)) target = find_model(string.slice!(0..string.index(' ')-1)) string.slice!(0..string.index(':')) string.strip! source = find_model(base_source.slice!(0..base_source.index('!')-1)) base_source.slice!(0) source.username = base_source.slice!(0..base_source.index('@')-1) base_source.slice!(0) source.address = base_source.strip source.source = orig_source source.save_changes source.add_channel(target) if target.is_a?(Models::Channel) return Messages::Incoming::Privmsg.new(orig, source, target, string) rescue Object => boom Logger.warn("Failed to parse PRIVMSG message: #{orig}") Logger.warn("Reason for PRIVMSG failure: #{boom}") raise boom end end |