Module: IIRC::Channels

Included in:
Batteries
Defined in:
lib/iirc/modules/channels.rb

Overview

Keeps track of the channels we are currently in. The list can be retrieved with #channels. Based on JOIN, PART and KICK messages received for our nick.

Instance Method Summary collapse

Instance Method Details

#channelsSet<String>

Returns:

  • (Set<String>)


7
8
9
# File 'lib/iirc/modules/channels.rb', line 7

def channels
  @channels ||= Set.new
end

#configure_channel_trackingObject (private)



12
13
14
# File 'lib/iirc/modules/channels.rb', line 12

def configure_channel_tracking
  hook :track_own_channels
end

#track_own_channels(evt) ⇒ Object (private)



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/iirc/modules/channels.rb', line 16

def track_own_channels(evt)
  case evt.verb
  when :'001'
    channels.clear
  when :join
    if me === evt.sender
      for c in evt.target.split(',')
        channels << c
      end
    end
  when :part
    if me === evt.sender
      for c in evt.target.split(',')
        channels.delete(c)
      end
    end
  when :kick
    if me === evt.args[1]
      channels.delete(evt.target)
    end
  end
end