… | |
… | |
5 | |
5 | |
6 | our $ConnectionClass = 'Net::IRC3::Connection'; |
6 | our $ConnectionClass = 'Net::IRC3::Connection'; |
7 | |
7 | |
8 | =head1 NAME |
8 | =head1 NAME |
9 | |
9 | |
10 | Net::IRC3 - An IRC Protocol module which is event system independend |
10 | Net::IRC3 - An event system independend IRC protocol module |
11 | |
11 | |
12 | =head1 VERSION |
12 | =head1 VERSION |
13 | |
13 | |
14 | Version 0.21 |
14 | Version 0.3 |
15 | |
15 | |
16 | =cut |
16 | =cut |
17 | |
17 | |
18 | our $VERSION = '0.21'; |
18 | our $VERSION = '0.3'; |
19 | |
19 | |
20 | =head1 SYNOPSIS |
20 | =head1 SYNOPSIS |
21 | |
21 | |
|
|
22 | Using the simplistic L<Net::IRC3::Connection>: |
|
|
23 | |
|
|
24 | use AnyEvent; |
22 | use Net::IRC3::Connection; |
25 | use Net::IRC3::Connection; |
|
|
26 | |
|
|
27 | my $c = AnyEvent->condvar; |
23 | |
28 | |
24 | my $con = new Net::IRC3::Connection; |
29 | my $con = new Net::IRC3::Connection; |
25 | |
30 | |
26 | $con->connect ("test.not.at.irc.net", 6667); |
31 | $con->connect ("localhost", 6667); |
27 | |
32 | |
|
|
33 | $con->reg_cb (irc_001 => sub { print "$_[1]->{prefix} says i'm in the IRC: $_[1]->{trailing}!\n"; $c->broadcast; 0 }); |
|
|
34 | $con->send_msg (undef, NICK => undef, "testbot"); |
|
|
35 | $con->send_msg (undef, USER => 'testbot', "testbot", '*', '0'); |
|
|
36 | |
|
|
37 | $c->wait; |
|
|
38 | |
|
|
39 | Using the more sophisticatd L<Net::IRC3::Client::Connection>: |
|
|
40 | |
|
|
41 | use AnyEvent; |
|
|
42 | use Net::IRC3::Client::Connection; |
|
|
43 | |
|
|
44 | my $c = AnyEvent->condvar; |
|
|
45 | |
|
|
46 | my $timer; |
|
|
47 | my $con = new Net::IRC3::Client::Connection; |
|
|
48 | |
|
|
49 | $con->reg_cb (registered => sub { print "I'm in!\n"; 0 }); |
|
|
50 | $con->reg_cb (disconnect => sub { print "I'm out!\n"; 0 }); |
|
|
51 | $con->reg_cb ( |
|
|
52 | sent => sub { |
|
|
53 | if ($_[2] eq 'PRIVMSG') { |
|
|
54 | print "Sent message!\n"; |
|
|
55 | $timer = AnyEvent->timer (after => 1, cb => sub { $c->broadcast }); |
|
|
56 | } |
|
|
57 | 1 |
|
|
58 | } |
|
|
59 | ); |
|
|
60 | |
|
|
61 | $con->send_srv (PRIVMSG => "Hello there i'm the cool Net::IRC3 test script!", 'elmex'); |
|
|
62 | |
|
|
63 | $con->connect ("localhost", 6667); |
|
|
64 | $con->register (qw/testbot testbot testbot/); |
|
|
65 | |
|
|
66 | $c->wait; |
|
|
67 | undef $timer; |
|
|
68 | |
|
|
69 | $con->disconnect; |
28 | |
70 | |
29 | =head1 DESCRIPTION |
71 | =head1 DESCRIPTION |
30 | |
72 | |
31 | L<Net::IRC3> itself is a simple building block for an IRC client. |
73 | The L<Net::IRC3> module consists of L<Net::IRC3::Connection>, L<Net::IRC3::Client::Connection> |
|
|
74 | and L<Net::IRC3::Util>. L<Net::IRC3> only contains this documentation. |
32 | It manages connections and parses and constructs IRC messages. |
75 | It manages connections and parses and constructs IRC messages. |
33 | |
76 | |
34 | L<Net::IRC3> is I<very> simple, if you don't want to care about |
77 | L<Net::IRC3> is I<very> simple, if you don't want to care about |
35 | all the other things that a client still has to do (like replying to |
78 | all the other things that a client still has to do (like replying to |
36 | PINGs and remembering who is on a channel), I recommend to read |
79 | PINGs and remembering who is on a channel), I recommend to read |