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

# Content
1 #!/usr/bin/perl
2 use strict;
3 use Event;
4 use Net::IRC3::Client::Connection;
5 $Net::IRC3::Client::Connection::DEBUG = 1;
6
7 my $c = AnyEvent->condvar;
8
9 my $pc = Net::IRC3::Client::Connection->new;
10
11 $pc->connect ("irc.plan9.de", 6667);
12
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 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 $pc->enable_ping (2);
46 },
47 disconnect => sub {
48 print "DISCOPNNECT ($_[1])!!!\n";
49 }
50 );
51
52 # 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
59 $c->wait;