ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Net-IRC3/samples/netirc3cl
Revision: 1.6
Committed: Mon Jul 17 15:09:20 2006 UTC (20 years, 2 months ago) by elmex
Branch: MAIN
Changes since 1.5: +3 -4 lines
Log Message:
simplyfied the whole module a bit.

File Contents

# User Rev Content
1 elmex 1.1 #!/usr/bin/perl
2     use strict;
3 elmex 1.3 use Net::IRC3::Client::Connection;
4 elmex 1.6 $Net::IRC3::Client::Connection::DEBUG = 1;
5 elmex 1.1
6     my $c = AnyEvent->condvar;
7    
8 elmex 1.6 my $pc = Net::IRC3::Client::Connection->new;
9 elmex 1.1
10 elmex 1.6 $pc->connect ("irc.plan9.de", 6667);
11 elmex 1.1
12     $pc->reg_cb (
13     irc_privmsg => sub {
14     my ($self, $msg) = @_;
15     if ($msg->{trailing} =~ m/net_irc3:\s*(.*)/) {
16     $pc->send_chan ("#test", "PRIVMSG", "yes?", "#test");
17     }
18     }
19     );
20    
21     $pc->reg_cb (
22 elmex 1.4 channel_add => sub {
23     my ($self, $chan, @nicks) = @_;
24     my $nick = join ",", @nicks;
25    
26     print "$chan += $nick\n";
27     print "chans: " . (join ";", keys %{$self->channel_list}) ."\n";
28     print "nicks: " . (join ";", keys %{$self->channel_list ()->{$chan}}) ."\n";
29     },
30     channel_remove => sub {
31     my ($self, $chan, @nicks) = @_;
32     my $nick = join ",", @nicks;
33    
34     print "$chan -= $nick\n";
35     print "chans: " . (join ";", keys %{$self->channel_list}) ."\n";
36     print "nicks: " . (join ";", keys %{$self->channel_list ()->{$chan}}) ."\n";
37     }
38     );
39    
40     $pc->reg_cb (
41     registered => sub {
42     my ($self) = @_;
43     print "registered!\n";
44     },
45 elmex 1.1 disconnect => sub {
46     print "DISCOPNNECT!!!\n";
47     }
48     );
49    
50 elmex 1.3 # these commands will queue until the connection
51     # is completly registered and has a valid nick etc.
52     $pc->send_srv ("JOIN", undef, "#test");
53     $pc->send_chan ("#test", "PRIVMSG", "hi, i'm a bot!", "#test");
54    
55     $pc->register ("net_irc3", "net_irc3", "test bot");
56 elmex 1.1
57     $c->wait;