ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Net-IRC3/samples/notify
Revision: 1.1
Committed: Mon Jul 17 16:01:04 2006 UTC (20 years, 2 months ago) by elmex
Branch: MAIN
CVS Tags: HEAD
Log Message:
added examples and documentation

File Contents

# User Rev Content
1 elmex 1.1 #!perl
2     use AnyEvent;
3     use Net::IRC3::Client::Connection;
4    
5     my $c = AnyEvent->condvar;
6    
7     my $timer;
8     my $con = new Net::IRC3::Client::Connection;
9    
10     $con->reg_cb (registered => sub { print "I'm in!\n"; 0 });
11     $con->reg_cb (disconnect => sub { print "I'm out!\n"; 0 });
12     $con->reg_cb (
13     sent => sub {
14     if ($_[2] eq 'PRIVMSG') {
15     print "Sent message!\n";
16     $timer = AnyEvent->timer (after => 1, cb => sub { $c->broadcast });
17     }
18     1
19     }
20     );
21    
22     $con->send_srv (PRIVMSG => "Hello there i'm the cool Net::IRC3 test script!", 'elmex');
23    
24     $con->connect ("localhost", 6667);
25     $con->register (qw/testbot testbot testbot/);
26    
27     $c->wait;
28     undef $timer;
29    
30     $con->disconnect;