Class: ModSpox::Handlers::Join

Inherits:
Handler
  • Object
show all
Defined in:
lib/mod_spox/handlers/Join.rb

Instance Method Summary collapse

Methods inherited from Handler

#preprocess

Constructor Details

#initialize(handlers) ⇒ Join

Returns a new instance of Join.



5
6
7
# File 'lib/mod_spox/handlers/Join.rb', line 5

def initialize(handlers)
    handlers[:JOIN] = self
end

Instance Method Details

#process(string) ⇒ Object

:mod_spox!~mod_spox@host JOIN :#m



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mod_spox/handlers/Join.rb', line 11

def process(string)
    orig = string.dup
    string = string.dup
    begin
        string.slice!(0)
        source = string.slice!(0..string.index(' ')-1)
        string.slice!(0..string.index(':'))
        channel = find_model(string.strip)
        nick = find_model(source.slice(0..source.index('!')-1))
        nick.source = source.dup
        source.slice!(0..source.index('!'))
        nick.username = source.slice!(0..source.index('@')-1)
        source.slice!(0)
        nick.address = source.slice!(0..source.size)
        nick.visible = true
        nick.save_changes
        channel.add_nick(nick)
        channel.save
        return Messages::Incoming::Join.new(orig, channel, nick)
    rescue Object => boom
        Logger.warn("Failed to parse JOIN message: #{orig}")
        raise boom
    end
end