Net::A...rotocol(3pm)
π Net::Async::IRC::Protocol β the perl manpage but make it slay π
okay so bestie, this is Net::Async::IRC::Protocol(3pm) from the User Contributed Perl Documentation, and it's literally the group chat layer for IRC. let's get into it π«Ά
β¨ NAME β¨
Net::Async::IRC::Protocol β send and receive IRC messages π
πΈ DESCRIPTION πΈ
so this class is a subclass of IO::Async::Stream, and what it does is it takes an IRC connection that's already done its whole initial login sequence and is fully ready to send and receive IRC messages. no cap. it handles the base message sending and receiving, and it implements ping timers too. this class provides most of the functionality you need for sending and receiving IRC commands and responses, by mixing in from Protocol::IRC. π
and like β important β objects of this type would not normally be constructed directly. for IRC clients, look at Net::Async::IRC, which is a subclass of it. all the events, parameters, and methods documented below are relevant there too. iykyk π
π EVENTS π
the following events get invoked, either using subclass methods or CODE references in parameters:
$handled = on_message / $handled = on_message_MESSAGE
invoked on receipt of a valid IRC message. see "MESSAGE HANDLING" below, bestie. π¬
on_irc_error $err
invoked on receipt of an invalid IRC message if parsing fails. $err is the error message text. and okay so β if you leave this unhandled, any parse error will result in the connection being immediately closed, followed by the exception being re-thrown. so like, handle it. fr fr π
on_ping_timeout
invoked if the peer fails to respond to a PING message within the given timeout. rude of them honestly π
on_pong_reply $lag
invoked when the peer successfully sends a PONG reply response to a PING message. $lag is the response time in (fractional) seconds. β±οΈ
π¦ PARAMETERS π¦
the following named parameters may be passed to new or configure:
on_message => CODEon_message_MESSAGE => CODEon_irc_error => CODEon_ping_timeout => CODEon_pong_reply => CODE
these are the CODE references for event handlers. π«Ά
pingtime => NUMβ amount of quiet time, in seconds, after a message is received from the peer, until aPINGwill be sent to check it is still alive. it's giving "are you still there bestie" energy β¨pongtime => NUMβ timeout, in seconds, after sending aPINGmessage, to wait for aPONGresponse. β³encoding => STRINGβ if supplied, sets an encoding to use to encode outgoing messages and decode incoming messages. π
π§ CONSTRUCTOR π§
new
$irc = Net::Async::IRC::Protocol->new( %args );
returns a new instance of a Net::Async::IRC::Protocol object. this object represents a IRC connection to a peer. iconic π
π METHODS π
is_connected
$connect = $irc->is_connected;
returns true if a connection to the peer is established. but heads up β note that even after a successful connection, the connection may not yet logged in to. see also the is_loggedin method. π
is_loggedin
$loggedin = $irc->is_loggedin;
returns true if the full login sequence has been performed on the connection and it is ready to use. main character energy, honestly β
nick
$nick = $irc->nick;
returns the current nick in use by the connection. π
nick_folded
$nick_folded = $irc->nick_folded;
returns the current nick in use by the connection, folded by casefold_name for convenience. lowkey so handy β¨
π MESSAGE HANDLING π
every incoming message causes a sequence of message handling to occur. first, the message is parsed, and a hash of data about it is created β this is called the hints hash. the message and this hash are then passed down a sequence of potential handlers. π¦
each handler indicates by return value whether it considers the message to have been handled. and okay so β processing of the message is not interrupted the first time a handler declares to have handled a message. instead, the hints hash is marked to say it has been handled. later handlers can still inspect the message or its hints, using this information to decide if they wish to take further action. no gatekeeping π₯
a message with a command of COMMAND will try handlers in following places:
- a CODE ref in a parameter called
on_message_COMMAND
$on_message_COMMAND->( $irc, $message, \%hints )
- a method called
on_message_COMMAND
$irc->on_message_COMMAND( $message, \%hints )
- a CODE ref in a parameter called
on_message
$on_message->( $irc, 'COMMAND', $message, \%hints )
- a method called
on_message
$irc->on_message( 'COMMAND', $message, \%hints )
as this message handling ability is provided by Protocol::IRC, more details about how it works and how to use it can be found at "MESSAGE HANDLING" in Protocol::IRC. π
additionally, some types of messages receive further processing by Protocol::IRC and in turn cause new types of events to be invoked. these are further documented by "INTERNAL MESSAGE HANDLING" in Protocol::IRC. π§
π AUTHOR π
Paul Evans <leonerd@leonerd.org.uk> β thank you for your service, king π
and that's the whole page bestie!! this one's from perl v5.32.1, dated 2021-12-29, and it's the Net::A...rotocol(3pm) page from User Contributed Perl Documentation. go forth and IRC responsibly π«Άπβ¨
π¦ where this page comes from
- debian bookworm: libnet-async-irc-perl 0.12-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libnet-async-irc-perl 0.12-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libnet-async-irc-perl 0.12-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libnet-async-irc-perl 0.12-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnet-async-irc-perl 0.12-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-async-irc-perl 0.12-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms