Class: MessageFactory::Handlers::Mode
- Defined in:
- lib/messagefactory/handlers/MODE.rb
Instance Method Summary collapse
-
#process(string) ⇒ Object
- string
-
string to process Create a new Mode message OpenStruct will contain: #type #direction #raw #received #source #target #channel #modes #set #unset :nodoc: :spax!~spox@host MODE #m o spax :nodoc: :spax MODE spax :iw.
- #types_process ⇒ Object
Instance Method Details
#process(string) ⇒ Object
- string
-
string to process
Create a new Mode message OpenStruct will contain: #type #direction #raw #received #source #target #channel #modes #set #unset :nodoc: :spax!~spox@host MODE #m o spax :nodoc: :spax MODE spax :iw
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/messagefactory/handlers/MODE.rb', line 15 def process(string) string = string.dup orig = string.dup m = nil self_mode = string.index('!').nil? begin m = mk_struct(string) m.type = :mode string.slice!(0) m.source = string.slice!(0, string.index(' ')) string.slice!(0) raise 'error' unless string.slice!(0, string.index(' ')).to_sym == :MODE string.slice!(0) if(self_mode) m.target = string.slice!(0, string.index(' ')) string.slice!(0, string.index(':')+1) action = string.slice!(0).chr m.set = action == '+' m.unset = action == '-' m.modes = string else m.channel = string.slice!(0, string.index(' ')) string.slice!(0) action = string.slice!(0).chr m.set = action == '+' m.unset = action == '-' m.modes = string.slice!(0, string.index(' ')) string.slice!(0) m.target = string m.nick_mode = Hash[m.target.split.zip(m.modes.split(''))] end rescue raise "Failed to parse Mode message: #{orig}" end m end |
#types_process ⇒ Object
6 7 8 |
# File 'lib/messagefactory/handlers/MODE.rb', line 6 def types_process :MODE end |