Skip to content

Instantly share code, notes, and snippets.

@issm
Created November 18, 2012 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save issm/4105302 to your computer and use it in GitHub Desktop.
Save issm/4105302 to your computer and use it in GitHub Desktop.
sample using AnyEvent::IRC::Client
use 5.12.0;
use warnings;
use utf8;
use AnyEvent;
use AnyEvent::IRC::Client;
use Encode;
my @server_info = (
'irc.example.com',
6667,
{
nick => 'foobar',
real => 'foobar',
password => '********',
},
);
my @channels = (
'#meganelab',
);
my $cv = AnyEvent->condvar;
my $irc = AnyEvent::IRC::Client->new;
$irc->reg_cb(
registered => sub {
warn 'registered';
},
disconnect => sub {
warn 'disconnected';
},
publicmsg => sub {
my ($irc, $channel, $ircmsg) = @_;
my (undef, $who) = $irc->split_nick_mode($ircmsg->{prefix});
my $msg = decode_utf8( $ircmsg->{params}[1] // '' );
sleep 1;
$irc->send_chan( $channel, 'NOTICE', $channel, encode_utf8("Re: $msg") );
},
);
$irc->connect(@server_info);
for (@channels) {
$irc->send_srv('JOIN', $_);
}
$cv->recv;
$irc->disconnect;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment