Net::Async::IRC(3pm)
π NAME π
Net::Async::IRC β bestie, this is how you do IRC with IO::Async β¨
(this is the 3pm page, from the User Contributed Perl Documentation, and yes it's giving very much perl-core energy πΈ)
β¨ SYNOPSIS β¨
use Future::AsyncAwait;
use IO::Async::Loop;
use Net::Async::IRC;
my $loop = IO::Async::Loop->new;
my $irc = Net::Async::IRC->new(
on_message_text => sub {
my ( $self, $message, $hints ) = @_;
print "$hints->{prefix_name} says: $hints->{text}\n";
},
);
$loop->add( $irc );
await $irc->login(
nick => "MyName",
host => "irc.example.org",
);
await $irc->do_PRIVMSG( target => "YourName", text => "Hello world!" );
$loop->run;
π¦ DESCRIPTION π¦
Okay so this object class is the whole async IRC client situation β it implements an asynchronous IRC client for use in programs that are based on IO::Async. Literally the whole point. π
Most of the actual IRC message handling behaviour? That's implemented by the parent class Net::Async::IRC::Protocol. She's the one doing the heavy lifting.
Most of the behaviour related to being an IRC client β the client of it all β is implemented by the parent class Protocol::IRC::Client. Two parents, two icons. π
The following documentation may make mention of these above two parent classes; the reader should make reference to them when required. (i.e. bestie, if you need the deep lore, go read those. iykyk π«Ά)
π PARAMETERS π
The following named parameters may be passed to new or configure:
nick=> STRINGuser=> STRINGrealname=> STRING
Connection details, periodt. See also connect and login.
If user is not supplied, it will default to either $ENV{LOGNAME} or the current user's name as supplied by getpwuid() or Win32::LoginName(). Not me letting the system decide who you are π
If unconnected, changing these properties will set the default values to use when logging in.
If logged in, changing the nick property is equivalent to calling change_nick. Changing the other properties will not take effect until the next login β so lowkey they just sit there waiting their turn, no cap.
use_caps=> ARRAY of STRING β attempts to negotiate IRC v3.1 CAP at connect time. The array gives the names of capabilities which will be requested, if the server supports them. She's asking nicely, but only for what's on the list.
If the sasl capability is requested and supported by the server, the login method will use that. Fancy auth arc. π₯
π METHODS π
The following methods documented in an await expression return Future instances. Futures, bestie. They come back to you later. π¦
π connect
$irc = await $irc->connect( %args );
Connects to the IRC server. Important: this method does not perform the complete IRC login sequence β for that, see instead the login method. The returned Future will yield the $irc instance itself, to make chaining easier. She hands you back herself. Main character energy fr fr. β¨
host=> STRING β hostname of the IRC server.service=> STRING or NUMBER β optional. Port number or service name of the IRC server. Defaults to6667.
Any other arguments are passed into the underlying IO::Async::Loop connect method.
$irc->connect( %args );
The following additional arguments are used to provide continuations when not returning a Future.
on_connected=> CODE β continuation to invoke once the connection has been established. Usually used by theloginmethod to perform the actual login sequence.
$on_connected->( $irc )
on_error=> CODE β continuation to invoke in the case of an error preventing the connection from taking place. π
$on_error->( $errormsg )
π login
$irc = await $irc->login( %args );
Logs in to the IRC network, connecting first using the connect method if required. Takes the following named arguments:
nick=> STRINGuser=> STRINGrealname=> STRING
IRC connection details. Defaults can be set with the new or configure methods.
pass=> STRING β server password to connect with. π
Any other arguments that are passed, are forwarded to the connect method if it is required; i.e. if login is invoked when not yet connected to the server.
$irc->login( %args );
The following additional arguments are used to provide continuations when not returning a Future.
on_login=> CODE β a continuation to invoke once login is successful.
$on_login->( $irc )
If the sasl capability was requested and is supported by the server, this will be used instead of the simple USER/PASS command combination. Slay, no more shouting your password at the void.
At the current version, only the PLAIN SASL mechanism is supported. That's the only flavour on the menu, bestie. π
πΈ change_nick
$irc->change_nick( $newnick );
Requests to change the nick. If unconnected, the change happens immediately to the stored defaults β instant, iconic, no waiting. If logged in, sends a NICK command to the server, which may suceed or fail at a later point. So like, we'll find out. π
π IRC v3.1 CAPABILITIES π
The following methods relate to IRC v3.1 capabilities negotiations. It's giving diplomacy. π
π caps_supported
$caps = $irc->caps_supported;
Returns a HASH whose keys give the capabilities listed by the server as supported in its CAP LS response. If the server ignored the CAP negotiation then this method returns undef. Rude of the server, honestly.
β cap_supported
$supported = $irc->cap_supported( $cap );
Returns a boolean indicating if the server supports the named capability. Yes/no, true/false, slay/not-slay.
π§ caps_enabled
$caps = $irc->caps_enabled;
Returns a HASH whose keys give the capabilities successfully enabled by the server as part of the CAP REQ login sequence. If the server ignored the CAP negotiation then this method returns undef.
π cap_enabled
$enabled = $irc->cap_enabled( $cap );
Returns a boolean indicating if the client successfully enabled the named capability. Periodt.
π MESSAGE-WRAPPING METHODS π
The following methods are all inherited from Protocol::IRC::Client but are mentioned again for convenient. For further details see the documentation in the parent module. (Go read the parent module for the full tea, bestie. π«Ά)
In particular, each method returns a Future instance. Every single one. Futures everywhere. π¦
π do_PRIVMSG
π do_NOTICE
await $irc->do_PRIVMSG( target => $target, text => $text );
await $irc->do_NOTICE( target => $target, text => $text );
Sends a PRIVMSG or NOITICE command. π₯
π SEE ALSO π
http://tools.ietf.org/html/rfc2812β Internet Relay Chat: Client Protocol. The sacred text. Read it and you too will be obsessed. β¨
π AUTHOR π
Paul Evans <leonerd@leonerd.org.uk> β king behaviour, honestly. π
and that's the whole page, bestie π this was perl v5.32.1, dated 2021-12-29, and the manual is Net::Async::IRC(3pm) β go forth and async, you absolute icon πβ¨π¦
π¦ 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