IRC.pm

filter: Statementstmt 100% 8 / 8 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 100% 10 / 10 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« IRC/Connection.pm ↑ Summary
1 package AnyEvent::IRC;
2 1 ▶use common::sense;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use AnyEvent;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 =head1 NAME
6  
7 AnyEvent::IRC - An event based IRC protocol client API
8  
9 =head1 VERSION
10  
11 Version 0.97
12  
13 =cut
14  
15 1 our $VERSION = '0.97';
16  
17 =head1 SYNOPSIS
18  
19 Using the simplistic L<AnyEvent::IRC::Connection>:
20  
21 use AnyEvent;
22 use AnyEvent::IRC::Connection;
23  
24 my $c = AnyEvent->condvar;
25  
26 my $con = new AnyEvent::IRC::Connection;
27  
28 $con->connect ("localhost", 6667);
29  
30 $con->reg_cb (
31 connect => sub {
32 my ($con) = @_;
33 $con->send_msg (NICK => 'testbot');
34 $con->send_msg (USER => 'testbot', '*', '0', 'testbot');
35 },
36 irc_001 => sub {
37 my ($con) = @_;
38 print "$_[1]->{prefix} says I'm in the IRC: $_[1]->{params}->[-1]!\n";
39 $c->broadcast;
40 }
41 );
42  
43 $c->wait;
44  
45 Using the more sophisticated L<AnyEvent::IRC::Client>:
46  
47 use AnyEvent;
48 use AnyEvent::IRC::Client;
49  
50 my $c = AnyEvent->condvar;
51  
52 my $timer;
53 my $con = new AnyEvent::IRC::Client;
54  
55 $con->reg_cb (registered => sub { print "I'm in!\n"; });
56 $con->reg_cb (disconnect => sub { print "I'm out!\n"; $c->broadcast });
57 $con->reg_cb (
58 sent => sub {
59 my ($con) = @_;
60  
61 if ($_[2] eq 'PRIVMSG') {
62 print "Sent message!\n";
63  
64 $timer = AnyEvent->timer (
65 after => 1,
66 cb => sub {
67 undef $timer;
68 $con->disconnect ('done')
69 }
70 );
71 }
72 }
73 );
74  
75 $con->send_srv (
76 PRIVMSG => 'elmex',
77 "Hello there I'm the cool AnyEvent::IRC test script!"
78 );
79  
80 $con->connect ("localhost", 6667, { nick => 'testbot' });
81 $c->wait;
82 $con->disconnect;
83  
84 =head1 DESCRIPTION
85  
86 The L<AnyEvent::IRC> module consists of L<AnyEvent::IRC::Connection>,
87 L<AnyEvent::IRC::Client> and L<AnyEvent::IRC::Util>. L<AnyEvent::IRC>
88 is just a module that holds this overview over the other modules.
89  
90 L<AnyEvent::IRC> can be viewed as toolbox for handling IRC connections
91 and communications. It won't do everything for you, and you still
92 need to know a few details of the IRC protocol.
93  
94 L<AnyEvent::IRC::Client> is a more highlevel IRC connection
95 that already processes some messages for you and will generated some
96 events that are maybe useful to you. It will also do PING replies for you,
97 manage channels a bit, nicknames and CTCP.
98  
99 L<AnyEvent::IRC::Connection> is a lowlevel connection that only connects
100 to the server and will let you send and receive IRC messages.
101 L<AnyEvent::IRC::Connection> does not imply any client behaviour, you could also
102 use it to implement an IRC server.
103  
104 Note that these modules use L<AnyEvent> as it's IO event subsystem.
105 You can integrate them into any application with a event system
106 that L<AnyEvent> has support for (eg. L<Gtk2> or L<Event>).
107  
108 =head1 EXAMPLES
109  
110 See the samples/ directory for some examples on how to use AnyEvent::IRC.
111  
112 =head1 AUTHOR
113  
114 Robin Redeker, C<< <elmex@ta-sa.org> >>
115  
116 =head1 SEE ALSO
117  
118 L<AnyEvent::IRC::Util>
119  
120 L<AnyEvent::IRC::Connection>
121  
122 L<AnyEvent::IRC::Client>
123  
124 L<AnyEvent>
125  
126 RFC 1459 - Internet Relay Chat: Client Protocol
127  
128 RFC 2812 - Internet Relay Chat: Client Protocol
129  
130 =head1 BUGS
131  
132 Please report any bugs or feature requests to
133 C<bug-net-irc3 at rt.cpan.org>, or through the web interface at
134 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=AnyEvent-IRC>.
135 I will be notified, and then you'll automatically be notified of progress on
136 your bug as I make changes.
137  
138 =head1 SUPPORT
139  
140 You can find documentation for this module with the perldoc command.
141  
142 perldoc AnyEvent::IRC
143  
144 You can also look for information at:
145  
146 =over 4
147  
148 =item * AnnoCPAN: Annotated CPAN documentation
149  
150 L<http://annocpan.org/dist/AnyEvent-IRC>
151  
152 =item * CPAN Ratings
153  
154 L<http://cpanratings.perl.org/d/AnyEvent-IRC>
155  
156 =item * RT: CPAN's request tracker
157  
158 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=AnyEvent-IRC>
159  
160 =item * Search CPAN
161  
162 L<http://search.cpan.org/dist/AnyEvent-IRC>
163  
164 =back
165  
166 =head1 ACKNOWLEDGEMENTS
167  
168 Thanks to Marc Lehmann for the new AnyEvent module!
169  
170 And these people have helped to work on L<AnyEvent::IRC>:
171  
172 * Maximilian Gass - Added support for ISUPPORT and CASEMAPPING.
173 * Zaba - Thanks for the useful input about IRC.
174 * tokuhirom - Thanks for patches for the kick event.
175 * Kazuhiro Osawa - Thanks for the documenation fix.
176 * Angel Abad - Thanks for the spelling fixes.
177 * Lee Aylward - Thanks for bug spotting and fixing.
178  
179 =head1 COPYRIGHT & LICENSE
180  
181 Copyright 2006-2009 Robin Redeker, all rights reserved.
182  
183 This program is free software; you can redistribute it and/or modify it
184 under the same terms as Perl itself.
185  
186 =cut
187  
188 1 1;
« IRC/Connection.pm ↑ Summary