line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Moses; |
2
|
2
|
|
|
2
|
|
29468
|
use MooseX::POE (); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use Moose::Exporter; |
4
|
|
|
|
|
|
|
use Adam; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = $Adam::VERSION; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Moose::Exporter->setup_import_methods( |
9
|
|
|
|
|
|
|
with_caller => [ |
10
|
|
|
|
|
|
|
qw( |
11
|
|
|
|
|
|
|
nickname |
12
|
|
|
|
|
|
|
server |
13
|
|
|
|
|
|
|
port |
14
|
|
|
|
|
|
|
channels |
15
|
|
|
|
|
|
|
plugins |
16
|
|
|
|
|
|
|
username |
17
|
|
|
|
|
|
|
owner |
18
|
|
|
|
|
|
|
flood |
19
|
|
|
|
|
|
|
password |
20
|
|
|
|
|
|
|
poco_irc_args |
21
|
|
|
|
|
|
|
poco_irc_options |
22
|
|
|
|
|
|
|
) |
23
|
|
|
|
|
|
|
], |
24
|
|
|
|
|
|
|
also => [qw(MooseX::POE)], |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub init_meta { |
28
|
|
|
|
|
|
|
my ( $class, %args ) = @_; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $for = $args{for_class}; |
31
|
|
|
|
|
|
|
eval qq{ |
32
|
|
|
|
|
|
|
package $for; |
33
|
|
|
|
|
|
|
use POE; |
34
|
|
|
|
|
|
|
use POE::Component::IRC::Common qw( :ALL ); |
35
|
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Moose->init_meta( |
38
|
|
|
|
|
|
|
for_class => $for, |
39
|
|
|
|
|
|
|
base_class => 'Adam' |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub nickname { |
44
|
|
|
|
|
|
|
my ( $caller, $name ) = @_; |
45
|
|
|
|
|
|
|
my $class = Moose::Meta::Class->initialize($caller); |
46
|
|
|
|
|
|
|
$class->add_method( 'default_nickname' => sub { return $name } ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub server { |
50
|
|
|
|
|
|
|
my ( $caller, $name ) = @_; |
51
|
|
|
|
|
|
|
my $class = Moose::Meta::Class->initialize($caller); |
52
|
|
|
|
|
|
|
$class->add_method( 'default_server' => sub { return $name } ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub port { |
56
|
|
|
|
|
|
|
my ( $caller, $port ) = @_; |
57
|
|
|
|
|
|
|
my $class = Moose::Meta::Class->initialize($caller); |
58
|
|
|
|
|
|
|
$class->add_method( 'default_port' => sub { return $port } ); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub channels { |
62
|
|
|
|
|
|
|
my ( $caller, @channels ) = @_; |
63
|
|
|
|
|
|
|
my $class = Moose::Meta::Class->initialize($caller); |
64
|
|
|
|
|
|
|
$class->add_method( 'default_channels' => sub { return \@channels } ); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub plugins { |
68
|
|
|
|
|
|
|
my ( $caller, %plugins ) = @_; |
69
|
|
|
|
|
|
|
my $class = Moose::Meta::Class->initialize($caller); |
70
|
|
|
|
|
|
|
$class->add_method( 'custom_plugins' => sub { return \%plugins } ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub username { |
74
|
|
|
|
|
|
|
my ( $caller, $username ) = @_; |
75
|
|
|
|
|
|
|
my $class = Moose::Meta::Class->initialize($caller); |
76
|
|
|
|
|
|
|
$class->add_method( 'default_username' => sub { return $username } ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub password { |
80
|
|
|
|
|
|
|
my ( $caller, $password ) = @_; |
81
|
|
|
|
|
|
|
my $class = Moose::Meta::Class->initialize($caller); |
82
|
|
|
|
|
|
|
$class->add_method( 'default_password' => sub { return $password } ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub flood { |
86
|
|
|
|
|
|
|
my ( $caller, $flood ) = @_; |
87
|
|
|
|
|
|
|
my $class = Moose::Meta::Class->initialize($caller); |
88
|
|
|
|
|
|
|
$class->add_method( 'default_flood' => sub { return $flood } ); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub owner { |
92
|
|
|
|
|
|
|
my ( $caller, $owner ) = @_; |
93
|
|
|
|
|
|
|
my $class = Moose::Meta::Class->initialize($caller); |
94
|
|
|
|
|
|
|
$class->add_method( 'default_owner' => sub { return $owner } ); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub poco_irc_args { |
98
|
|
|
|
|
|
|
my ( $caller, %extra_args ) = @_; |
99
|
|
|
|
|
|
|
my $class = Moose::Meta::Class->initialize($caller); |
100
|
|
|
|
|
|
|
$class->add_method( 'default_poco_irc_args' => sub { return \%extra_args } |
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub poco_irc_options { |
105
|
|
|
|
|
|
|
my ( $caller, %options ) = @_; |
106
|
|
|
|
|
|
|
my $class = Moose::Meta::Class->initialize($caller); |
107
|
|
|
|
|
|
|
$class->add_method( 'default_poco_irc_options' => sub { return \%options } |
108
|
|
|
|
|
|
|
); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
112
|
|
|
|
|
|
|
__END__ |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 NAME |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Moses - A framework for building IRC bots quickly and easily. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 VERSION |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This documentation refers to version 0.04. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SYNOPSIS |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
package SampleBot; |
125
|
|
|
|
|
|
|
use Moses; |
126
|
|
|
|
|
|
|
use namespace::autoclean; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
server 'irc.perl.org'; |
129
|
|
|
|
|
|
|
nickname 'sample-bot'; |
130
|
|
|
|
|
|
|
channels '#bots'; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
has message => ( |
133
|
|
|
|
|
|
|
isa => 'Str', |
134
|
|
|
|
|
|
|
is => 'rw', |
135
|
|
|
|
|
|
|
default => 'Hello', |
136
|
|
|
|
|
|
|
); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
event irc_bot_addressed => sub { |
139
|
|
|
|
|
|
|
my ( $self, $nickstr, $channel, $msg ) = @_[ OBJECT, ARG0, ARG1, ARG2 ]; |
140
|
|
|
|
|
|
|
my ($nick) = split /!/, $nickstr; |
141
|
|
|
|
|
|
|
$self->privmsg( $channel => "$nick: ${ \$self->message }" ); |
142
|
|
|
|
|
|
|
}; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
__PACKAGE__->run unless caller; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 DESCRIPTION |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Moses is some declarative sugar for building an IRC bot based on the |
149
|
|
|
|
|
|
|
L<Adam|Adam> IRC Bot. Moses is designed to minimize the amount of work you |
150
|
|
|
|
|
|
|
have to do to make an IRC bot functional, and to make the process as |
151
|
|
|
|
|
|
|
declarative as possible. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 FUNCTIONS |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head2 nickname (Str $name) |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Set the nickname for the bot. Default's to the current package. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 username(Str) |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
The username which we should use |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 password(Str) |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
The server password which we shoulduse |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 server (Str $server) |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Set the server for the bot. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 port (Int $port) |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Set the port for the bot's server. Default's to 6667. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 owner (Str) |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
The hostmask of the ower of the bot. The owner can control the bot's plugins |
178
|
|
|
|
|
|
|
through IRC using the <POE::Component::IRC::Plugin::Plugman|Plugman> |
179
|
|
|
|
|
|
|
interface. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head2 flood (Bool) |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Disable flood protection. Defaults to False. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head2 channels (@channels) |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Supply a list of channels for the bot to join upon connecting. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head2 plugins (@plugins) |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Extra L<POE::Component::IRC::Plugin|POE::Component::IRC::Plugin> objects or |
192
|
|
|
|
|
|
|
class names to load into the bot. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head2 extra_args (HashRef) |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
A list of extra arguments to pass to the irc constructor. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
The same dependencies as L<Adam|Adam>. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
L<MooseX::POE|MooseX::POE>, L<namespace::autoclean|namespace::autoclean>, |
204
|
|
|
|
|
|
|
L<MooseX::Alias|MooseX::Alias>, L<POE::Component::IRC|POE::Component::IRC>, |
205
|
|
|
|
|
|
|
L<MooseX::Getopt|MooseX::Getopt>, |
206
|
|
|
|
|
|
|
L<MooseX::SimpleConfig|MooseX::SimpleConfig>, |
207
|
|
|
|
|
|
|
L<MooseX::LogDispatch|MooseX::LogDispatch> |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
None known currently, please email the author if you find any. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 AUTHOR |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Chris Prather (chris@prather.org) |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head1 LICENCE |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Copyright 2007-2009 by Chris Prather. |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
This software is free. It is licensed under the same terms as Perl itself. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=cut |