ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Net-IRC3/samples/netirc3cl
Revision: 1.7
Committed: Thu Apr 19 20:12:58 2007 UTC (19 years, 5 months ago) by elmex
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +3 -1 lines
Log Message:
implemented enable_ping

File Contents

# User Rev Content
1 elmex 1.1 #!/usr/bin/perl
2     use strict;
3 elmex 1.7 use Event;
4 elmex 1.3 use Net::IRC3::Client::Connection;
5 elmex 1.6 $Net::IRC3::Client::Connection::DEBUG = 1;
6 elmex 1.1
7     my $c = AnyEvent->condvar;
8    
9 elmex 1.6 my $pc = Net::IRC3::Client::Connection->new;
10 elmex 1.1
11 elmex 1.6 $pc->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 elmex 1.7 $pc->enable_ping (2);
46 elmex 1.4 },
47 elmex 1.1 disconnect => sub {
48 elmex 1.7 print "DISCOPNNECT ($_[1])!!!\n";
49 elmex 1.1 }
50     );
51    
52 elmex 1.3 # these commands will queue until the connection
53     # is completly registered and has a valid nick etc.
54     $pc->send_srv ("JOIN", undef, "#test");
55     $pc->send_chan ("#test", "PRIVMSG", "hi, i'm a bot!", "#test");
56    
57     $pc->register ("net_irc3", "net_irc3", "test bot");
58 elmex 1.1
59     $c->wait;