Class: MessageFactory::Handlers::Privmsg

Inherits:
Handler
  • Object
show all
Defined in:
lib/messagefactory/handlers/PRIVMSG.rb

Instance Method Summary collapse

Instance Method Details

#process(string) ⇒ Object

string

string to process

Create a new Privmsg message OpenStruct will contain: #type #direction #raw #received #source #target #message :nodoc: I thoguht about adding in #public and #private methods and something for the nick a message is addressing, but we want to keep this stuff simple, so we will let the implementation program worry about extras like that. :nodoc: :spox!~spox@host PRIVMSG #m :foobar :nodoc: :spox!~spox@host PRIVMSG mod_spox :foobar



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/messagefactory/handlers/PRIVMSG.rb', line 20

def process(string)
    string = string.dup
    m = mk_struct(string)
    begin
        m.type = :privmsg
        string.slice!(0)
        m.source = string.slice!(0, string.index(' '))
        string.slice!(0)
        raise 'error' unless string.slice!(0, string.index(' ')).to_sym == :PRIVMSG
        string.slice!(0)
        m.target = string.slice!(0, string.index(' '))
        string.slice!(0, string.index(':')+1)
        m.message = string
    rescue
        raise "Failed to parse Privmsg message: #{m.raw}"
    end
    m
end

#types_processObject



7
8
9
# File 'lib/messagefactory/handlers/PRIVMSG.rb', line 7

def types_process
    :PRIVMSG
end