ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Net-IRC3/samples/netirc3cl
Revision: 1.5
Committed: Sun Jul 16 19:44:50 2006 UTC (20 years, 2 months ago) by elmex
Branch: MAIN
Changes since 1.4: +1 -1 lines
Log Message:
moved utilitys to Util.pm and fixed a bug in nick chasing

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 elmex 1.4 #$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.5 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 elmex 1.4 channel_add => sub {
24     my ($self, $chan, @nicks) = @_;
25     my $nick = join ",", @nicks;
26    
27     print "$chan += $nick\n";
28     print "chans: " . (join ";", keys %{$self->channel_list}) ."\n";
29     print "nicks: " . (join ";", keys %{$self->channel_list ()->{$chan}}) ."\n";
30     },
31     channel_remove => sub {
32     my ($self, $chan, @nicks) = @_;
33     my $nick = join ",", @nicks;
34    
35     print "$chan -= $nick\n";
36     print "chans: " . (join ";", keys %{$self->channel_list}) ."\n";
37     print "nicks: " . (join ";", keys %{$self->channel_list ()->{$chan}}) ."\n";
38     }
39     );
40    
41     $pc->reg_cb (
42     registered => sub {
43     my ($self) = @_;
44     print "registered!\n";
45     },
46 elmex 1.1 disconnect => sub {
47     print "DISCOPNNECT!!!\n";
48     }
49     );
50    
51 elmex 1.3 # these commands will queue until the connection
52     # is completly registered and has a valid nick etc.
53     $pc->send_srv ("JOIN", undef, "#test");
54     $pc->send_chan ("#test", "PRIVMSG", "hi, i'm a bot!", "#test");
55    
56     $pc->register ("net_irc3", "net_irc3", "test bot");
57 elmex 1.1
58     $c->wait;