Protocol::IRC::Client - IRC protocol handling for a client
Protocol::IRC::Client
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:
Protocol::IRC
isupport
$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.
005 ISUPPORT
$info = $irc->server_info( $key )
Returns an item of information from the server's 004 line. $key should one of
004
$key
host
version
usermodes
channelmodes
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.
more
WHOIS
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:
done
fail
$data
A method called on_gate_EFFECT_GATE
on_gate_EFFECT_GATE
$client->on_gate_EFFECT_GATE( $message, $hints, $data )
A method called on_gate_EFFECT
on_gate_EFFECT
$client->on_gate_EFFECT( 'GATE', $message, $hints, $data )
A method called on_gate
on_gate
$client->on_gate( 'EFFECT, 'GATE', $message, $hints, $data )
The following messages are handled internally by Protocol::IRC::Client.
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
CAP
verb
caps
$irc->on_message_cap_VERB( $message, \%hints )
or
$irc->on_message_cap( 'VERB', $message, \%hints )
These messages 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:
type
The mode relates to a list; bans, invites, etc..
The mode sets a value about the channel
The mode is a simple boolean flag about the channel
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 -.
mode
sense
+
-
For list and value types, the value key gives the actual list entry or value being set.
list
value
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.
occupant
flag
prefix_mode2flag
nick
nick_folded
boolean types do not create any extra keys.
boolean
These messages will be collected up, per channel, by the message gating system, and formed into a single synthesized event called who.
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:
These messages will be collected up, per channel, by the message gating system, and formed into a single synthesized event called names.
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:
These messages will be collected up, per channel, by the message gating system, and formed into a single synthesized event called bans.
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:
User mask of the ban
Nickname of the user who set the ban
UNIX timestamp the ban was created
These messages will be collected up, by the message gating system, into a synthesized event called motd.
motd
Its hints hash will contain an extra key, motd, which will be an ARRAY ref containing the lines of the MOTD.
These messages will be collected up, by the message gating system, into a synthesized event called whois.
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.
RPL_WHOIS*
RPL_WHOIS
Paul Evans <leonerd@leonerd.org.uk>
To install Protocol::IRC, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Protocol::IRC
CPAN shell
perl -MCPAN -e shell install Protocol::IRC
For more information on module installation, please visit the detailed CPAN module installation guide.