Module: IRC

Defined in:
lib/wires/ircbot.rb,
lib/wires/ircbot/user.rb,
lib/wires/ircbot/events.rb,
lib/wires/ircbot/handlers.rb,
lib/wires/ircbot/overrides.rb

Defined Under Namespace

Classes: Bot, User

Class Method Summary collapse

Class Method Details

.parse_message(m) ⇒ Object



5
6
7
8
9
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
36
37
38
39
40
41
42
43
# File 'lib/wires/ircbot/events.rb', line 5

def self.parse_message m
  if m.command=='376'
    return [end_of_motd:[
      prefix:  m.prefix,
      target:  m.args[0],
      text:    m.args[1..-1].join(' ')[1..-1]
    ]]
  end
  
  if m.command=='PING'
    return [ping:[
      prefix:  m.args[0],
      target: (m.args[1] or m.args[0])
    ]]
  end
  
  if m.command=='PRIVMSG'
    return [privmsg:[
      user:   (User.new m.prefix),
      channel: m.args[0],
      text:    m.args[1..-1].join(' ')[1..-1]
    ]]
  end
  
  if m.command=='JOIN'
    return [join:[
      user:   (User.new m.prefix),
      channel: m.args[0]
    ]]
  end
  
  if m.command=='PART'
    return [part:[
      user:   (User.new m.prefix),
      channel: m.args[0],
      text:    m.args[1..-1].join(' ')[1..-1]
    ]]
  end
end