NAME
Protocol::IRC::Client - IRC protocol handling for a client
DESCRIPTION
This mix-in class provides a layer of IRC message handling logic suitable for an IRC client. It builds upon Protocol::IRC to provide extra message processing useful to IRC clients, such as handling inbound server numerics.
It provides some of the methods required by Protocol::IRC:
isupport
METHODS
$value = $irc->isupport( $key )
Returns an item of information from the server's 005 ISUPPORT lines. Traditionally IRC servers use all-capital names for keys.
$info = $irc->server_info( $key )
Returns an item of information from the server's 004 line. $key should one of
host
version
usermodes
channelmodes
GATING MESSAGES
If messages with a gating disposition are received, extra processing is applied. Messages whose gating effect is more are simply collected up by pushing the hints hash to an array. Added to this hash is the command name itself, so that in the case of multiple message types (for example WHOIS replies) the individual messages can still be identified.
When the effect of done or fail is eventually received, this collected array is passed as $data to a handler in one of the following places:
A method called
on_gate_EFFECT_GATE$client->on_gate_EFFECT_GATE( $message, $hints, $data )A method called
on_gate_EFFECT$client->on_gate_EFFECT( 'GATE', $message, $hints, $data )A method called
on_gate$client->on_gate( 'EFFECT, 'GATE', $message, $hints, $data )
INTERNAL MESSAGE HANDLING
The following messages are handled internally by Protocol::IRC::Client.
CAP
This message takes a sub-verb as its second argument, and a list of capability names as its third. On receipt of a CAP message, the verb is extracted and set as the verb hint, and the list capabilities set as the keys of a hash given as the caps hint. These are then passed to an event called
$irc->on_message_cap_VERB( $message, \%hints )
or
$irc->on_message_cap( 'VERB', $message, \%hints )
MODE (on channels) and 324 (RPL_CHANNELMODEIS)
These message involve channel modes. The raw list of channel modes is parsed into an array containing one entry per affected piece of data. Each entry will contain at least a type key, indicating what sort of mode or mode change it is:
- list
-
The mode relates to a list; bans, invites, etc..
- value
-
The mode sets a value about the channel
- bool
-
The mode is a simple boolean flag about the channel
- occupant
-
The mode relates to a user in the channel
Every mode type then provides a mode key, containing the mode character itself, and a sense key which is an empty string, +, or -.
For list and value types, the value key gives the actual list entry or value being set.
For occupant types, a flag key gives the mode converted into an occupant flag (by the prefix_mode2flag method), nick and nick_folded store the user name affected.
boolean types do not create any extra keys.
RPL_WHOREPLY and RPL_ENDOFWHO
These messages will be collected up, per channel, and formed into a single synthesized event called who.
Its hints hash will contain an extra key, who, which will be an ARRAY ref containing the lines of the WHO reply. Each line will be a HASH reference containing:
- user_ident
- user_host
- user_server
- user_nick
- user_nick_folded
- user_flags
RPL_NAMEREPLY and RPL_ENDOFNAMES
These messages will be collected up, per channel, and formed into a single synthesized event called names.
Its hints hash will contain an extra key, names, which will be an ARRAY ref containing the usernames in the channel. Each will be a HASH reference containing:
- nick
- flag
RPL_BANLIST and RPL_ENDOFBANS
These messages will be collected up, per channel, and formed into a single synthesized event called bans.
Its hints hash will contain an extra key, bans, which will be an ARRAY ref containing the ban lines. Each line will be a HASH reference containing:
- mask
-
User mask of the ban
- by_nick
- by_nick_folded
-
Nickname of the user who set the ban
- timestamp
-
UNIX timestamp the ban was created
RPL_MOTD, RPL_MOTDSTART and RPL_ENDOFMOTD
These messages will be collected up into a synthesized event called motd.
Its hints hash will contain an extra key, motd, which will be an ARRAY ref containing the lines of the MOTD.
RPL_WHOIS* and RPL_ENDOFWHOIS
These messages will be collected up into a synthesized event called whois.
Each RPL_WHOIS* reply will be stripped of the standard hints hash keys, leaving whatever remains. Added to this will be a key called whois, whose value will be the command name, minus the leading RPL_WHOIS, and converted to lowercase.
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>