Module: IIRC::Members

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

Overview

Note:

IIRC doesn't send NAMES by itself, but will process any replies received, such as to JOIN, or any requests you have made yourself.

Processes lists of channel participants sent by the server into #members.
Namely, it processes NAMES replies, such as the ones sent automatically when we join a channel.

Instance Method Summary collapse

Instance Method Details

#configure_members_trackingObject (private)

Note:

In a future release, this may also track using JOIN/KICK/PART, etc.



18
19
20
21
# File 'lib/iirc/modules/members.rb', line 18

def configure_members_tracking
  on :'353', :receive_names
  on :'366', :receive_names_end
end

#membersHash<String,[String]>

Nicknames present in channels, by channel. Updated from NAMES replies.

Returns:

  • (Hash<String,[String]>)


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

def members
  @members ||= {}
end

#members_receivingHash (private)

Returns:

  • (Hash)


35
36
37
# File 'lib/iirc/modules/members.rb', line 35

def members_receiving
  @members_receiving ||= Hash.new { |h,k| h[k] = [] }
end

#receive_names(evt) ⇒ Object (private)



23
24
25
26
27
# File 'lib/iirc/modules/members.rb', line 23

def receive_names evt
  names = evt.args[3]
  channel = evt.args[2]
  members_receiving[channel].concat names.tr('&+@%~', '').split(' ')
end

#receive_names_end(evt) ⇒ Object (private)



29
30
31
32
# File 'lib/iirc/modules/members.rb', line 29

def receive_names_end evt
  channel = evt.args[1]
  members[channel] = members_receiving.delete(channel)
end