1 |
elmex |
1.1 |
package Net::IRC3; |
2 |
|
|
use strict; |
3 |
|
|
use AnyEvent; |
4 |
|
|
use IO::Socket::INET; |
5 |
elmex |
1.2 |
|
6 |
elmex |
1.3 |
our $ConnectionClass = 'Net::IRC3::Connection'; |
7 |
elmex |
1.2 |
|
8 |
elmex |
1.1 |
=head1 NAME |
9 |
|
|
|
10 |
elmex |
1.8 |
Net::IRC3 - An event system independend IRC protocol module |
11 |
elmex |
1.1 |
|
12 |
|
|
=head1 VERSION |
13 |
|
|
|
14 |
elmex |
1.13 |
Version 0.5 |
15 |
elmex |
1.1 |
|
16 |
|
|
=cut |
17 |
|
|
|
18 |
elmex |
1.13 |
our $VERSION = '0.5'; |
19 |
elmex |
1.1 |
|
20 |
|
|
=head1 SYNOPSIS |
21 |
|
|
|
22 |
elmex |
1.8 |
Using the simplistic L<Net::IRC3::Connection>: |
23 |
|
|
|
24 |
|
|
use AnyEvent; |
25 |
elmex |
1.7 |
use Net::IRC3::Connection; |
26 |
elmex |
1.1 |
|
27 |
elmex |
1.8 |
my $c = AnyEvent->condvar; |
28 |
|
|
|
29 |
elmex |
1.7 |
my $con = new Net::IRC3::Connection; |
30 |
elmex |
1.1 |
|
31 |
elmex |
1.8 |
$con->connect ("localhost", 6667); |
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 |
elmex |
1.1 |
|
69 |
elmex |
1.8 |
$con->disconnect; |
70 |
elmex |
1.1 |
|
71 |
|
|
=head1 DESCRIPTION |
72 |
|
|
|
73 |
elmex |
1.8 |
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. |
75 |
elmex |
1.1 |
It manages connections and parses and constructs IRC messages. |
76 |
|
|
|
77 |
elmex |
1.9 |
L<Net::IRC3::Connection> is I<very> simple, if you don't want to care about |
78 |
elmex |
1.1 |
all the other things that a client still has to do (like replying to |
79 |
|
|
PINGs and remembering who is on a channel), I recommend to read |
80 |
elmex |
1.9 |
the L<Net::IRC3::Client::Connection> page instead. |
81 |
elmex |
1.1 |
|
82 |
elmex |
1.9 |
Note that the *::Connection module uses AnyEvent as it's IO event subsystem. |
83 |
|
|
You can integrate them into any application with a event system |
84 |
elmex |
1.4 |
that AnyEvent has support for (eg. L<Gtk2> or L<Event>). |
85 |
|
|
|
86 |
elmex |
1.2 |
=head1 EXAMPLES |
87 |
elmex |
1.1 |
|
88 |
elmex |
1.2 |
See the samples/ directory for some examples on how to use Net::IRC3. |
89 |
elmex |
1.1 |
|
90 |
|
|
=head1 AUTHOR |
91 |
|
|
|
92 |
|
|
Robin Redeker, C<< <elmex@ta-sa.org> >> |
93 |
|
|
|
94 |
|
|
=head1 SEE ALSO |
95 |
|
|
|
96 |
elmex |
1.14 |
L<Net::IRC3::Util> |
97 |
|
|
|
98 |
elmex |
1.2 |
L<Net::IRC3::Connection> |
99 |
|
|
|
100 |
elmex |
1.11 |
L<Net::IRC3::Client::Connection> |
101 |
elmex |
1.2 |
|
102 |
elmex |
1.4 |
L<AnyEvent> |
103 |
|
|
|
104 |
elmex |
1.1 |
RFC 2812 - Internet Relay Chat: Client Protocol |
105 |
|
|
|
106 |
|
|
=head1 BUGS |
107 |
|
|
|
108 |
|
|
Please report any bugs or feature requests to |
109 |
|
|
C<bug-net-irc3 at rt.cpan.org>, or through the web interface at |
110 |
|
|
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-IRC3>. |
111 |
|
|
I will be notified, and then you'll automatically be notified of progress on |
112 |
|
|
your bug as I make changes. |
113 |
|
|
|
114 |
|
|
=head1 SUPPORT |
115 |
|
|
|
116 |
|
|
You can find documentation for this module with the perldoc command. |
117 |
|
|
|
118 |
|
|
perldoc Net::IRC3 |
119 |
|
|
|
120 |
|
|
You can also look for information at: |
121 |
|
|
|
122 |
|
|
=over 4 |
123 |
|
|
|
124 |
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
125 |
|
|
|
126 |
|
|
L<http://annocpan.org/dist/Net-IRC3> |
127 |
|
|
|
128 |
|
|
=item * CPAN Ratings |
129 |
|
|
|
130 |
|
|
L<http://cpanratings.perl.org/d/Net-IRC3> |
131 |
|
|
|
132 |
|
|
=item * RT: CPAN's request tracker |
133 |
|
|
|
134 |
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-IRC3> |
135 |
|
|
|
136 |
|
|
=item * Search CPAN |
137 |
|
|
|
138 |
|
|
L<http://search.cpan.org/dist/Net-IRC3> |
139 |
|
|
|
140 |
|
|
=back |
141 |
|
|
|
142 |
|
|
=head1 ACKNOWLEDGEMENTS |
143 |
|
|
|
144 |
|
|
Thanks to Marc Lehmann for the new AnyEvent module! |
145 |
|
|
|
146 |
|
|
=head1 COPYRIGHT & LICENSE |
147 |
|
|
|
148 |
elmex |
1.10 |
Copyright 2006 Robin Redeker, all rights reserved. |
149 |
elmex |
1.1 |
|
150 |
|
|
This program is free software; you can redistribute it and/or modify it |
151 |
|
|
under the same terms as Perl itself. |
152 |
|
|
|
153 |
|
|
=cut |
154 |
|
|
|
155 |
|
|
1; |