ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Net-IRC3/samples/netirc3cl
Revision: 1.3
Committed: Sun Jul 16 11:11:17 2006 UTC (20 years, 2 months ago) by elmex
Branch: MAIN
Changes since 1.2: +9 -6 lines
Log Message:
version 0.2. added documentation and refactored code a bit.

File Contents

# User Rev Content
1 elmex 1.1 #!/usr/bin/perl
2     use strict;
3     use Net::IRC3::Client;
4 elmex 1.3 use Net::IRC3::Client::Connection;
5     $Net::IRC3::Client::Connection::DEBUG = 1;
6 elmex 1.1
7     my $c = AnyEvent->condvar;
8    
9     my $i = Net::IRC3::Client->new;
10    
11 elmex 1.3 my $pc = $i->connect ("irc.plan9.de", 6667);
12 elmex 1.1
13     $pc->reg_cb (
14     irc_privmsg => sub {
15     my ($self, $msg) = @_;
16     if ($msg->{trailing} =~ m/net_irc3:\s*(.*)/) {
17     $pc->send_chan ("#test", "PRIVMSG", "yes?", "#test");
18     }
19     }
20     );
21    
22     $pc->reg_cb (
23     disconnect => sub {
24     print "DISCOPNNECT!!!\n";
25     }
26     );
27    
28 elmex 1.3 # these commands will queue until the connection
29     # is completly registered and has a valid nick etc.
30     $pc->send_srv ("JOIN", undef, "#test");
31     $pc->send_chan ("#test", "PRIVMSG", "hi, i'm a bot!", "#test");
32    
33     $pc->register ("net_irc3", "net_irc3", "test bot");
34 elmex 1.1
35     $c->wait;