6 our $VERSION = 0.001004;
9 use POE
::Component
::IRC
::State
;
10 use POE
::Component
::IRC
::Plugin
::AutoJoin
;
11 use POE
::Component
::IRC
::Plugin
::NickServID
;
13 use File
::Slurp qw
/append_file/;
14 use IRC
::Utils qw
/parse_user/;
17 use POSIX qw
/strftime/;
18 use Regexp
::Common qw
/net/;
20 ##################################################
24 my $server='irc.oftc.net';
35 "password=s" => \
$password,
36 "server=s" => \
$server,
39 "channel=s" => \
@channels,
41 "store-files!" => \
$store_files,
48 my ($channel, $nick)=@_;
49 return '~' if $irc->is_channel_owner($channel, $nick);
50 return '&' if $irc->is_channel_admin($channel, $nick);
51 return '@' if $irc->is_channel_operator($channel, $nick);
52 return '%' if $irc->is_channel_halfop($channel, $nick);
53 return '+' if $irc->has_channel_voice($channel, $nick);
59 my ($channel, @strings) = @_;
60 my $file=strftime
'%F', localtime;
62 mkdir "logs/$channel";
63 append_file
"logs/$channel/$file.txt", strftime
('%T ', localtime), @strings, "\n";
67 $irc->plugin_add (NickServID
=> POE
::Component
::IRC
::Plugin
::NickServID
->new(Password
=> $password)) if defined $password;
68 $irc->plugin_add (AutoJoin
=> POE
::Component
::IRC
::Plugin
::AutoJoin
->new(
69 Channels
=> \
@channels,
72 Retry_when_banned
=> 60,
75 $server = $1 if $server =~ /^($RE{net}{domain})$/;
76 $port = $1 if $port =~ /^([0-9]+)$/;
78 $irc->yield(register
=> "all");
83 Ircname
=> "devbot $VERSION",
92 my ($fulluser, $channels, $message)=@_[ARG0
, ARG1
, ARG2
];
93 my $nick=parse_user
$fulluser;
96 my $mode_char=mode_char
$_, $nick;
97 log_event
$_, "<$mode_char$nick> $message";
102 my ($fulluser, $channels, $message)=@_[ARG0
, ARG1
, ARG2
];
103 my $nick=parse_user
$fulluser;
105 log_event
$_, "* $nick $message" for @
$channels;
109 my ($fulluser, $channel)=@_[ARG0
, ARG1
];
110 my ($nick, $user, $host)=parse_user
$fulluser;
112 log_event
$channel, "-!- $nick [$user\@$host] has joined $channel";
116 my ($fulluser, $channel, $message)=@_[ARG0
, ARG1
, ARG2
];
117 my ($nick, $user, $host)=parse_user
$fulluser;
119 log_event
$channel, "-!- $nick [$user\@$host] has left $channel [$message]";
123 my ($fulluser, $channel, $target, $message)=@_[ARG0
, ARG1
, ARG2
, ARG3
];
124 my $nick=parse_user
$fulluser;
126 log_event
$channel, "-!- $target was kicked from $channel by $nick [$message]";
130 my ($fulluser, $channel, @args)=@_[ARG0
.. $#_];
131 my $nick=parse_user
$fulluser;
132 my $mode=join ' ', @args;
134 log_event
$channel, "-!- mode/$channel [$mode] by $nick";
138 my ($fulluser, $channel, $topic)=@_[ARG0
, ARG1
, ARG2
];
139 my $nick=parse_user
$fulluser;
141 log_event
$channel, "-!- $nick changed the topic of $channel to: $topic" if $topic;
142 log_event
$channel, "-!- Topic unset by $nick on $channel" unless $topic;
146 my ($fulluser, $nick, $channels)=@_[ARG0
, ARG1
, ARG2
];
147 my $oldnick=parse_user
$fulluser;
149 log_event
$_, "-!- $oldnick is now known as $nick" for @
$channels;
153 my ($fulluser, $message, $channels)=@_[ARG0
, ARG1
, ARG2
];
154 my ($nick, $user, $host)=parse_user
$fulluser;
156 log_event
$_, "-!- $nick [$user\@$host] has quit [$message]" for @
$channels;
160 return unless $store_files;
161 my ($fulluser, $type, $cookie, $name)=@_[ARG0
, ARG1
, ARG3
, ARG4
];
162 my $nick=parse_user
$fulluser;
163 return unless $type eq 'SEND';
164 return unless $irc->nick_channels($nick);
165 return if $name =~ m
,/,;
168 $irc->yield(dcc_accept
=> $cookie, "files/$name");
172 $irc=POE
::Component
::IRC
::State
->spawn();
174 POE
::Session
->create(
176 _start
=> \
&bot_start
,
177 irc_public
=> \
&on_public
,
178 irc_ctcp_action
=> \
&on_ctcp_action
,
179 irc_join
=> \
&on_join
,
180 irc_part
=> \
&on_part
,
181 irc_kick
=> \
&on_kick
,
182 irc_mode
=> \
&on_mode
,
183 irc_topic
=> \
&on_topic
,
184 irc_nick
=> \
&on_nick
,
185 irc_quit
=> \
&on_quit
,
186 irc_dcc_request
=> \
&on_dcc_request
202 App::Devbot - IRC bot which helps development
211 App::Devbot is an IRC bot which helps developers collaborate.
213 Right now, it only does channel logging and file storage. It might do more in the future.
219 =item B<--nick> I<nickname>
221 The nickname of devbot. Defaults to devbot.
223 =item B<--password> I<password>
225 If supplied, identify to NickServ with this password
227 =item B<--server> I<hostname>
229 The server to connect to. Defaults to irc.oftc.net.
231 =item B<--port> I<port>
233 The port to connect to. Defaults to 6697.
235 =item B<--ssl>, B<--no-ssl>
237 B<--ssl> enables connecting to the server with SSL, B<--no-ssl> disables this. Defaults to B<--ssl>.
239 =item B<--channel> I<channel>
241 Makes devbot connect to I<channel>. Can be supplied multiple times for multiple channels. Has no default value.
243 =item B<--log>, B<--no-log>
245 B<--log> enables logging events to 'logs/I<CHANNEL>/I<DATE>.txt'. B<--no-log> disables logging. Defaults to B<--log>.
247 =item B<--store-files>, B<--no-store-files>
249 B<--store-files> enables storing files received via DCC to 'files/I<FILENAME>'. Files are only accepted if the sender and devbot share a channel. B<Only use when all channel users are trusted>. B<--no-store-files> disables storing files. Defaults to <--no-store-files>.
251 =item B<--trace>, B<--no-trace>
253 B<--trace> enables POE::Component::IRC::State tracing. Useful for debugging. B<--no-trace> disables tracing. Defaults to B<--no-trace>.
259 As stated above, the B<--store-files> option should only be used on private channels where every user is trusted.
263 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
265 =head1 COPYRIGHT AND LICENSE
267 Copyright (C) 2013 by Marius Gavrilescu
269 This library is free software; you can redistribute it and/or modify
270 it under the same terms as Perl itself, either Perl version 5.14.2 or,
271 at your option, any later version of Perl 5 you may have available.
This page took 0.037372 seconds and 4 git commands to generate.