An event based irc protocol client api
Version 0.97
Using the simplistic AnyEvent::IRC::Connection:
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;
Using the more sophisticated AnyEvent::IRC::Client:
use AnyEvent; use AnyEvent::IRC::Client;
my $c = AnyEvent->condvar;
my $timer; my $con = new AnyEvent::IRC::Client;
$con->reg_cb (registered => sub { print "I'm in!\n"; }); $con->reg_cb (disconnect => sub { print "I'm out!\n"; $c->broadcast }); $con->reg_cb ( sent => sub { my ($con) = @_;
if ($_[2] eq 'PRIVMSG') { print "Sent message!\n";
$timer = AnyEvent->timer ( after => 1, cb => sub { undef $timer; $con->disconnect ('done') } ); } } );
$con->send_srv ( PRIVMSG => 'elmex', "Hello there I'm the cool AnyEvent::IRC test script!" );
$con->connect ("localhost", 6667, { nick => 'testbot' }); $c->wait; $con->disconnect;
The AnyEvent::IRC module consists of AnyEvent::IRC::Connection, AnyEvent::IRC::Client and AnyEvent::IRC::Util. AnyEvent::IRC is just a module that holds this overview over the other modules.
AnyEvent::IRC can be viewed as toolbox for handling \s-1IRC\s0 connections and communications. It won't do everything for you, and you still need to know a few details of the \s-1IRC\s0 protocol.
AnyEvent::IRC::Client is a more highlevel \s-1IRC\s0 connection that already processes some messages for you and will generated some events that are maybe useful to you. It will also do \s-1PING\s0 replies for you, manage channels a bit, nicknames and \s-1CTCP\s0.
AnyEvent::IRC::Connection is a lowlevel connection that only connects to the server and will let you send and receive \s-1IRC\s0 messages. AnyEvent::IRC::Connection does not imply any client behaviour, you could also use it to implement an \s-1IRC\s0 server.
Note that these modules use AnyEvent as it's \s-1IO\s0 event subsystem. You can integrate them into any application with a event system that AnyEvent has support for (eg. Gtk2 or Event).
See the samples/ directory for some examples on how to use AnyEvent::IRC.
Robin Redeker, \*(C`<[email protected]>\*(C'
AnyEvent::IRC::Util
AnyEvent::IRC::Connection
AnyEvent::IRC::Client
AnyEvent
\s-1RFC\s0 1459 - Internet Relay Chat: Client Protocol
\s-1RFC\s0 2812 - Internet Relay Chat: Client Protocol
Please report any bugs or feature requests to \*(C`bug-net-irc3 at rt.cpan.org\*(C', or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=AnyEvent-IRC <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=AnyEvent-IRC>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc AnyEvent::IRC
You can also look for information at:
AnnoCPAN: Annotated \s-1CPAN\s0 documentation http://annocpan.org/dist/AnyEvent-IRC <http://annocpan.org/dist/AnyEvent-IRC>
\s-1CPAN\s0 Ratings http://cpanratings.perl.org/d/AnyEvent-IRC <http://cpanratings.perl.org/d/AnyEvent-IRC>
\s-1RT:\s0 \s-1CPAN\s0's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=AnyEvent-IRC <http://rt.cpan.org/NoAuth/Bugs.html?Dist=AnyEvent-IRC>
Search \s-1CPAN\s0 http://search.cpan.org/dist/AnyEvent-IRC <http://search.cpan.org/dist/AnyEvent-IRC>
Thanks to Marc Lehmann for the new AnyEvent module!
And these people have helped to work on AnyEvent::IRC:
* Maximilian Gass - Added support for ISUPPORT and CASEMAPPING. * Zaba - Thanks for the useful input about IRC. * tokuhirom - Thanks for patches for the kick event. * Kazuhiro Osawa - Thanks for the documenation fix. * Angel Abad - Thanks for the spelling fixes. * Lee Aylward - Thanks for bug spotting and fixing.
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.