AnyEvent::IRC::Connection(3pm) | User Contributed Perl Documentation | AnyEvent::IRC::Connection(3pm) |
AnyEvent::IRC::Connection - An IRC connection abstraction
use AnyEvent; use AnyEvent::IRC::Connection; my $c = AnyEvent->condvar; my $con = new AnyEvent::IRC::Connection; $con->connect ("localhost", 6667); $con->reg_cb ( connect => sub { my ($con) = @_; $con->send_msg (NICK => 'testbot'); $con->send_msg (USER => 'testbot', '*', '0', 'testbot'); }, irc_001 => sub { my ($con) = @_; print "$_[1]->{prefix} says I'm in the IRC: $_[1]->{params}->[-1]!\n"; $c->broadcast; } ); $c->wait;
The connection class. Here the actual interesting stuff can be done, such as sending and receiving IRC messages. And it also handles TCP connecting and even enabling of TLS.
Please note that CTCP support is available through the functions "encode_ctcp" and "decode_ctcp" provided by AnyEvent::IRC::Util.
NOTE: You are free to use the hash member "heap" (which contains a hash) to store any associated data with this object. For example retry timers or anything else.
You can also access that member via the "heap" method.
If you want to connect via TLS/SSL you have to call the "enable_ssl" method before to enable it.
$prepcb_or_timeout can either be a callback with the semantics of a prepare callback for the function "tcp_connect" in AnyEvent::Socket or a simple number which stands for a timeout.
Following events are emitted by this module and shouldn't be emitted from a module user call to "event". See also the documents Object::Event about registering event callbacks.
If you want to reestablish a connection, call "connect" again.
$con->reg_cb ( send => sub { my ($con, $ircmsg) = @_; if ($ircmsg->[1] eq 'NOTICE') { $con->stop_event; # prevent any notices from being sent. } elsif ($ircmsg->[1] eq 'PRIVMSG') { $ircmsg->[-1] =~ s/sex/XXX/i; # censor any outgoing private messages. } } );
Note: '<lowercase command>' stands for the command of the message in (ASCII) lower case.
Please note that this buffer is NOT the queue mentioned in AnyEvent::IRC::Client!
Robin Redeker, "<elmex@ta-sa.org>"
AnyEvent::IRC
AnyEvent::IRC::Client
Copyright 2006-2009 Robin Redeker, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2022-06-06 | perl v5.34.0 |