AnyEvent-IRC

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

          no reversed arguments anymore!
        - Added support for ISUPPORT and CASEMAPPING
	- Renamed from Net::IRC3 to AnyEvent::IRC
        - Using Object::Event, AnyEvent::Socket and AnyEvent::Handle
        - added buffer_empty event, to detect when the write buffer is empty.
        - changed send_msg() in that way that the prefix can't be given anymore,
          as AnyEvent::IRC is specialized on clients anyway.
        - Renamed AnyEvent::IRC::Client::Connection to AnyEvent::IRC::Client
        - Implemented prefix<=>mode mapping for nicks
        - Added test utility module and first automated connect test
        - Added debug_console example
        - Added mode tracking for users on channels, with NAMESX support
        - channel_list() now also optionally accepts the channel as first argument
        - the connect method of AnyEvent::IRC::Client now accepts an additional parameter
          where you can pass the register information for automatic registration.
        - the 'registered' event is now only emitted when the irc
          commands 376 or 422 have been seen.
        - added ctcp_auto_reply() method to AnyEvent::IRC::Client interface.
        - Util::mk_msg does NOT append "\015\012" anymore.
        - send_srv queue is now flushed in an event callback.

MANIFEST  view on Meta::CPAN

MANIFEST
README
Makefile.PL
lib/AnyEvent/IRC.pm
lib/AnyEvent/IRC/Util.pm
lib/AnyEvent/IRC/Client.pm
lib/AnyEvent/IRC/Connection.pm
samples/test_connect
samples/notify
samples/anyeventirccl
samples/debug_console
samples/version_dump
samples/anyeventirc
samples/dcc
t/00_load.t
t/01_util.t
META.yml                                 Module YAML meta-data (added by MakeMaker)
META.json                                Module JSON meta-data (added by MakeMaker)

lib/AnyEvent/IRC/Client.pm  view on Meta::CPAN

1459 or the string 'ERROR'. C<$message> is a description of the error.
C<$ircmsg> is the complete error irc message.

You may use AnyEvent::IRC::Util::rfc_code_to_name to convert C<$code> to the error
name from the RFC 2812. eg.:

   rfc_code_to_name ('471') => 'ERR_CHANNELISFULL'

NOTE: This event is also emitted when a 'ERROR' message is received.

=item debug_send => $command, @params

Is emitted everytime some command is sent.

=item debug_recv => $ircmsg

Is emitted everytime some command was received.

=back

=head1 METHODS

=over 4

=item $cl = AnyEvent::IRC::Client->new (%args)

lib/AnyEvent/IRC/Client.pm  view on Meta::CPAN

   $self->reg_cb (irc_352     => \&whoreply_cb);
   $self->reg_cb (irc_311     => \&whoisuser_cb);
   $self->reg_cb (irc_305     => \&away_change_cb);
   $self->reg_cb (irc_306     => \&away_change_cb);
   $self->reg_cb (irc_ping    => \&ping_cb);
   $self->reg_cb (irc_pong    => \&pong_cb);

   $self->reg_cb (irc_privmsg => \&privmsg_cb);
   $self->reg_cb (irc_notice  => \&privmsg_cb);

   $self->reg_cb ('irc_*'     => \&debug_cb);
   $self->reg_cb ('irc_*'     => \&anymsg_cb);
   $self->reg_cb ('irc_*'     => \&update_ident_cb);

   $self->reg_cb (disconnect  => \&disconnect_cb);

   $self->reg_cb (irc_332     => \&rpl_topic_cb);
   $self->reg_cb (irc_topic   => \&topic_change_cb);

   $self->reg_cb (ctcp        => \&ctcp_auto_reply_cb);

lib/AnyEvent/IRC/Client.pm  view on Meta::CPAN

}

=item $cl->send_msg (...)

See also L<AnyEvent::IRC::Connection>.

=cut

sub send_msg {
   my ($self, @a) = @_;
   $self->event (debug_send => @a);
   $self->SUPER::send_msg (@a);
}

=item $cl->send_srv ($command, @params)

This function sends an IRC message that is constructed by C<mk_msg (undef,
$command, @params)> (see L<AnyEvent::IRC::Util>). If the C<registered> event
has NOT yet been emitted the messages are queued until that event is emitted,
and then sent to the server.

lib/AnyEvent/IRC/Client.pm  view on Meta::CPAN


   if ($msg->{command} eq '305') { # no longer away
      delete $self->{away_status};
   } else { # away
      $self->{away_status} = 1;
   }

   $self->event (away_status_change => $self->{away_status});
}

sub debug_cb {
   my ($self, $msg) = @_;
   $self->event (debug_recv => $msg);
}

sub change_nick_login_cb {
   my ($self, $msg) = @_;

   if ($self->registered) {
      delete $self->{change_nick_cb_guard};

   } else {
      my $newnick = $self->{nick_change}->($self->nick);

samples/anyeventirc  view on Meta::CPAN

my $con = AnyEvent::IRC::Connection->new;


my ($nick, $user, $real) = qw/BinDepp BinDepp depp/;

$con->reg_cb (irc_001 => sub {
   my ($con) = @_;
   $con->event ('welcome'); # emit a self defined event
});

# display all irc messages for debugging
$con->reg_cb ('irc_*' => sub {
   my @p = @{delete $_[1]->{params} || []};
   warn "DEBUG: " . join ('|', %{$_[1]}, @p) . "\n";
});
$con->reg_cb ('sent'  => sub {
   shift; warn "DEBUG SENT: " . join ('|', @_) . "\n";
});

# we register now a callback on our self defined event
$con->reg_cb (welcome => sub {

samples/debug_console  view on Meta::CPAN

#!/usr/bin/env perl
# This is a simple script that connects stdin/stdout with a client
# connection to an irc server. the command line arguments are:
#
# $ ./debug_console <nick> <server> <port>
#
use common::sense;
use IO::Handle;
use AnyEvent;
use AnyEvent::IRC::Client;
use AnyEvent::IRC::Util qw/mk_msg parse_irc_msg encode_ctcp/;
use Data::Dumper;

my ($nick, $server, $port) = @ARGV;

samples/debug_console  view on Meta::CPAN


      if (defined $err) {
         warn "Couldn't connect: $err\n";
         $c->broadcast;
      } else {
         $stdout->push_write ("Connected!\n");
      }

      $con->register ($nick, $nick, $nick);
   },
   debug_recv => sub {
      my ($con, $msg) = @_;
      $stdout->push_write (
         "< "
         . mk_msg ($msg->{prefix}, $msg->{command}, @{$msg->{params}})
         . "\n"
      );
   },
   debug_send => sub {
      my ($con, @msg) = @_;
      $stdout->push_write (
         "> " . mk_msg (undef, @msg) . "\n"
      );
   },
   registered => sub {
      my ($con) = @_;

      my $stdin;
      $stdin = AnyEvent::Handle->new (



( run in 0.759 second using v1.01-cache-2.11-cpan-49f99fa48dc )