line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Copyright 2005, Karl Y. Pradene All rights reserved. |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Net::IRC2; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
44795
|
use strict; use warnings ; |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
5
|
use Exporter ; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
40
|
|
9
|
1
|
|
|
1
|
|
6
|
use Carp ; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
125
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw( Exporter ) ; |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw( new ) ; |
13
|
|
|
|
|
|
|
our @Export = qw( new ) ; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
5
|
use vars qw( $VERSION $DEBUG ) ; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
116
|
|
16
|
|
|
|
|
|
|
$VERSION = '0.27' ; |
17
|
|
|
|
|
|
|
$DEBUG = 0 ; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
0
|
0
|
|
0
|
|
|
sub new { shift and return bless {@_} } ; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub newconn { |
23
|
1
|
|
|
1
|
|
605
|
use Net::IRC2::Connection; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $self = shift; |
25
|
|
|
|
|
|
|
return $self->connections( Net::IRC2::Connection->new( @_, |
26
|
|
|
|
|
|
|
_parent => $self ) ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub add_default_handler { $_[0]->add_handler( [ 'WaterGate' ], $_[1] ) } |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub add_handler { map { $_->add_handler( @_ ) } @{ shift->connections } } |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub start { |
34
|
|
|
|
|
|
|
use threads; |
35
|
|
|
|
|
|
|
# FIXME |
36
|
|
|
|
|
|
|
my @threads = map { threads->create( sub { $_->start() } ) } @{$_[0]->connections}; |
37
|
|
|
|
|
|
|
map { $_->join } @threads ; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub connections { |
41
|
|
|
|
|
|
|
my ( $self, $param ) = @_ ; |
42
|
|
|
|
|
|
|
return $self->{'connections'} unless defined $param ; |
43
|
|
|
|
|
|
|
push @{$self->{'connections'}}, $param ; |
44
|
|
|
|
|
|
|
return $param ; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
sub callback { |
47
|
|
|
|
|
|
|
my ( $self, $param ) = @_ ; |
48
|
|
|
|
|
|
|
if ( ref $param eq 'CODE' ) { |
49
|
|
|
|
|
|
|
map { $_->callback( $param ) } @{ $self->connections } ; |
50
|
|
|
|
|
|
|
return 0 ; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
return $_[0]->{'callback'}( $param ) if defined $param ; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; # End of Net::IRC2 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Net::IRC2 - Client interface to the Internet Relay Chat protocol. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 VERSION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
!!! UNDER PROGRAMMING !!! |
66
|
|
|
|
|
|
|
You can use and feedback is welcome ( in english or french ) |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#This is the documentation for the Version __.__.__ of Net::IRC2 , released _______________. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=pod |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 SYNOPSIS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
use Net::IRC2 ; |
77
|
|
|
|
|
|
|
my $bot = new Net::IRC2 ; |
78
|
|
|
|
|
|
|
my $conn = $bot->newconn( uri => 'irc://Nick!User@localhost:6667/' ) ; |
79
|
|
|
|
|
|
|
$conn->mode( $conn->nick, '+B' ) ; |
80
|
|
|
|
|
|
|
$conn->mode( '#Ailleurs +m' ) ; |
81
|
|
|
|
|
|
|
$bot->add_default_handler( \&process_event ) ; |
82
|
|
|
|
|
|
|
$bot->start ; |
83
|
|
|
|
|
|
|
... |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 DESCRIPTION |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This module will provide you an access to the IRC protocol suitable to write your own IRC-Bots, or your |
88
|
|
|
|
|
|
|
IRC Client. The API will provide you the sames functions than Net::IRC, so change should be trivial. |
89
|
|
|
|
|
|
|
This module C |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 FUNCTIONS |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=over |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item new() |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
The constructor, takes no argument. Return a Net::IRC2 object. It's your IRC-Bot. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item newconn() |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Make a new connection. Like Net::IRC + can process a home-made tasty pseudo-URI : |
102
|
|
|
|
|
|
|
irc://Nick!User@localhost:6667/ . Yummy. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item start() |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Start the bot |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item add_handler() |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
set handler for all messages matching a command in commands list. |
111
|
|
|
|
|
|
|
$bot->add_handler( [ '001'..'005' ], \&function ) ; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item add_default_handler() |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
The simple way to handle all events with only one function. |
116
|
|
|
|
|
|
|
set handler for ALL messages |
117
|
|
|
|
|
|
|
$bot->add_default_handler( \&function ) ; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item connections() |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
return un ARRAY of Net::IRC2::Connection objects |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item irc_grammar() |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
! Internal ! |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item callback() |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
! DEPRECATED ! |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=back |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 BUGS |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
136
|
|
|
|
|
|
|
C, or through the web interface at |
137
|
|
|
|
|
|
|
L. |
138
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
139
|
|
|
|
|
|
|
your bug as I make changes. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 SEE ALSO |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Others Perl modules working with IRC connections: Net::IRC, POE::Component::IRC |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
IRC Request For Comment 1459 L |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 AUTHOR |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Karl Y. Pradene, C<< , irc://knotty@freenode.org/ >> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Copyright 2005, Karl Y. Pradene All rights reserved. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
This program is released under the following license: GNU General Public License, version 2 |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the terms |
158
|
|
|
|
|
|
|
of the GNU General Public License version 2 as published by the Free Software Foundation. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
161
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
162
|
|
|
|
|
|
|
See the GNU General Public License for more details. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with this program; |
165
|
|
|
|
|
|
|
if not, write to the |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Free Software Foundation, |
168
|
|
|
|
|
|
|
Inc., 51 Franklin St, Fifth Floor, |
169
|
|
|
|
|
|
|
Boston, MA 02110-1301 USA |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
See L |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |