Protocol-IRC
view release on metacpan or search on metacpan
For server numeric replies, if the numeric reply has a known name, it
will be attempted first at its known name, before falling back to the
numeric if it was not handled. Unrecognised numerics will be attempted
only at their numeric value.
Because of the wide variety of messages in IRC involving various types
of data the message handling specific cases for certain types of
message, including adding extra hints hash items, or invoking extra
message handler stages. These details are noted here.
Many of these messages create new events; called synthesized messages.
These are messages created by the Protocol::IRC object itself, to
better represent some of the details derived from the primary ones from
the server. These events all take lower-case command names, rather than
capitals, and will have a synthesized key in the hints hash, set to a
true value. These are dispatched and handled identically to regular
primary events, detailed above.
If any handler of the synthesized message returns true, then this marks
the primary message handled as well.
If a message is received that has a gating disposition, extra
processing is applied to it before the processing above. The effect on
its gate is given as a string (one of more, done, fail) to handlers in
the following places:
1. A method called on_message_gate_EFFECT_GATE
$irc->on_message_gate_EFFECT_GATE( $message, \%hints )
2. A method called on_message_gate_EFFECT
$irc->on_message_gate_EFFECT( 'GATE', $message, \%hints )
3. A method called on_message_gate
$irc->on_message_gate( 'EFFECT', 'GATE', $message, \%hints )
Message Hints
When messages arrive they are passed to the appropriate message
handling method, which the implementation may define. As well as the
message, a hash of extra information derived from or relating to the
message is also given.
The following keys will be present in any message hint hash:
handled => BOOL
Initially false. Will be set to true the first time a handler returns
a true value.
prefix_nick => STRING
prefix_user => STRING
prefix_host => STRING
Values split from the message prefix; see the Protocol::IRC::Message
prefix_split method.
prefix_name => STRING
Usually the prefix nick, or the hostname in case the nick isn't
defined (usually on server messages).
prefix_is_me => BOOL
True if the nick mentioned in the prefix refers to this connection.
Added to this set, will be all the values returned by the message's
named_args method. Some of these values may cause yet more values to be
generated.
If the message type defines a target_name:
* target_type => STRING
Either channel or user, as returned by classify_name.
* target_is_me => BOOL
True if the target name is a user and refers to this connection.
Any key whose name ends in _nick or _name will have a corresponding key
added with _folded suffixed on its name, containing the value
casefolded using casefold_name. This is for the convenience of string
comparisons, hash keys, etc..
Any of these keys that are not the prefix_name will additionally have a
corresponding key with _is_me replacing the _nick or _name, containing
the boolean result of calling the is_nick_me method on that name. This
makes it simpler to detect commands or results affecting the user the
connection represents.
METHODS
on_read
$irc->on_read( $buffer )
Informs the protocol implementation that more bytes have been read from
the peer. This method will modify the $buffer directly, and remove from
it the prefix of bytes it has consumed. Any bytes remaining should be
stored by the caller for next time.
Any messages found in the buffer will be passed, in sequence, to the
incoming_message method.
incoming_message
$irc->incoming_message( $message )
Invoked by the on_read method for every incoming IRC message. This
method implements the actual dispatch into various handler methods as
described in the "MESSAGE HANDLING" section above.
This method is exposed so that subclasses can override it, primarily to
wrap extra logic before or after the main dispatch (e.g. for logging or
other processing).
( run in 0.463 second using v1.01-cache-2.11-cpan-5511b514fd6 )