Class: ModSpox::Handlers::Notice
- Defined in:
- lib/mod_spox/handlers/Notice.rb
Instance Method Summary collapse
-
#initialize(handlers) ⇒ Notice
constructor
A new instance of Notice.
- #process(string) ⇒ Object
Methods inherited from Handler
Constructor Details
#initialize(handlers) ⇒ Notice
Returns a new instance of Notice.
5 6 7 |
# File 'lib/mod_spox/handlers/Notice.rb', line 5 def initialize(handlers) handlers[:NOTICE] = 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 28 29 30 31 |
# File 'lib/mod_spox/handlers/Notice.rb', line 9 def process(string) if(string =~ /:(\S+)\sNOTICE\s(\S+)\s:(.+)$/) base_source = $1 target = $2 = $3 if(base_source =~ /\!/) source = find_model(base_source.gsub(/!.+$/, '')) if(base_source =~ /!(.+)@(.+)$/) source.username == $1 source.address = $2 source.source = base_source source.save_changes end target = find_model(target) else source = base_source end return Messages::Incoming::Notice.new(string, source, target, ) else Logger.warn('Failed to match NOTICE message') return nil end end |