]>
iEval git - app-devbot.git/blob - lib/App/Devbot.pm
019bcc718eb5b7cfe75e33efceaa7b4d60c6341f
1 package App
:: Devbot
0.001002 ;
6 use POE
:: Component
:: IRC
:: State
;
7 use POE
:: Component
:: IRC
:: Plugin
:: AutoJoin
;
8 use POE
:: Component
:: IRC
:: Plugin
:: NickServID
;
10 use File
:: Slurp qw
/append_file/ ;
11 use IRC
:: Utils qw
/parse_user/ ;
14 use POSIX qw
/strftime/ ;
16 ##################################################
22 my $server = 'irc.oftc.net' ;
33 "password=s" => \
$password ,
34 "server=s" => \
$server ,
37 "channel=s" => \
@channels ,
39 "store-files!" => \
$store_files ,
46 my ( $channel , $nick )= @_ ;
47 return '~' if $irc -> is_channel_owner ( $channel , $nick );
48 return '&' if $irc -> is_channel_admin ( $channel , $nick );
49 return '@' if $irc -> is_channel_operator ( $channel , $nick );
50 return '%' if $irc -> is_channel_halfop ( $channel , $nick );
51 return '+' if $irc -> has_channel_voice ( $channel , $nick );
57 my ( $channel , @strings ) = @_ ;
58 my $file = strftime
' %F ' , localtime ;
60 mkdir "logs/ $channel " ;
61 append_file
"logs/ $channel / $file .txt" , strftime
( ' %T ' , localtime ), @strings , " \n " ;
65 $irc -> plugin_add ( NickServID
=> POE
:: Component
:: IRC
:: Plugin
:: NickServID
-> new ( Password
=> $password )) if defined $password ;
66 $irc -> plugin_add ( AutoJoin
=> POE
:: Component
:: IRC
:: Plugin
:: AutoJoin
-> new (
67 Channels
=> \
@channels ,
70 Retry_when_banned
=> 60 ,
73 $irc -> yield ( register
=> "all" );
78 Ircname
=> "devbot $VERSION " ,
87 my ( $fulluser , $channels , $message )= @_ [ ARG0
, ARG1
, ARG2
];
88 my $nick = parse_user
$fulluser ;
91 my $mode_char = mode_char
$_ , $nick ;
92 log_event
$_ , "< $mode_char $nick > $message " ;
97 my ( $fulluser , $channels , $message )= @_ [ ARG0
, ARG1
, ARG2
];
98 my $nick = parse_user
$fulluser ;
100 log_event
$_ , "* $nick $message " for @
$channels ;
104 my ( $fulluser , $channel )= @_ [ ARG0
, ARG1
];
105 my ( $nick , $user , $host )= parse_user
$fulluser ;
107 log_event
$channel , "-!- $nick [ $user \@ $host ] has joined $channel " ;
111 my ( $fulluser , $channel , $message )= @_ [ ARG0
, ARG1
, ARG2
];
112 my ( $nick , $user , $host )= parse_user
$fulluser ;
114 log_event
$channel , "-!- $nick [ $user \@ $host ] has left $channel [ $message ]" ;
118 my ( $fulluser , $channel , $target , $message )= @_ [ ARG0
, ARG1
, ARG2
, ARG3
];
119 my $nick = parse_user
$fulluser ;
121 log_event
$channel , "-!- $target was kicked from $channel by $nick [ $message ]" ;
125 my ( $fulluser , $channel , @args )= @_ [ ARG0
.. $#_ ];
126 my $nick = parse_user
$fulluser ;
127 my $mode = join ' ' , @args ;
129 log_event
$channel , "-!- mode/ $channel [ $mode ] by $nick " ;
133 my ( $fulluser , $channel , $topic )= @_ [ ARG0
, ARG1
, ARG2
];
134 my $nick = parse_user
$fulluser ;
136 log_event
$channel , "-!- $nick changed the topic of $channel to: $topic " if $topic ;
137 log_event
$channel , "-!- Topic unset by $nick on $channel " unless $topic ;
141 my ( $fulluser , $nick , $channels )= @_ [ ARG0
, ARG1
, ARG2
];
142 my $oldnick = parse_user
$fulluser ;
144 log_event
$_ , "-!- $oldnick is now known as $nick " for @
$channels ;
148 my ( $fulluser , $message , $channels )= @_ [ ARG0
, ARG1
, ARG2
];
149 my ( $nick , $user , $host )= parse_user
$fulluser ;
151 log_event
$_ , "-!- $nick [ $user \@ $host ] has quit [ $message ]" for @
$channels ;
155 return unless $store_files ;
156 my ( $fulluser , $type , $cookie , $name )= @_ [ ARG0
, ARG1
, ARG3
, ARG4
];
157 my $nick = parse_user
$fulluser ;
158 return unless $type eq 'SEND' ;
159 return unless $irc -> nick_channels ( $nick );
160 return if $name =~ m
,/,;
163 $irc -> yield ( dcc_accept
=> $cookie , "files/ $name " );
167 $irc = POE
:: Component
:: IRC
:: State
-> spawn ();
169 POE
:: Session
-> create (
171 _start
=> \
& bot_start
,
172 irc_public
=> \
& on_public
,
173 irc_ctcp_action
=> \
& on_ctcp_action
,
174 irc_join
=> \
& on_join
,
175 irc_part
=> \
& on_part
,
176 irc_kick
=> \
& on_kick
,
177 irc_mode
=> \
& on_mode
,
178 irc_topic
=> \
& on_topic
,
179 irc_nick
=> \
& on_nick
,
180 irc_quit
=> \
& on_quit
,
181 irc_dcc_request
=> \
& on_dcc_request
197 App::Devbot - IRC bot which helps development
206 App::Devbot is an IRC bot which helps developers collaborate.
208 Right now, it only does channel logging and file storage. It might do more in the future.
214 =item B<--nick> I<nickname>
216 The nickname of devbot. Defaults to devbot.
218 =item B<--password> I<password>
220 If supplied, identify to NickServ with this password
222 =item B<--server> I<hostname>
224 The server to connect to. Defaults to irc.oftc.net.
226 =item B<--port> I<port>
228 The port to connect to. Defaults to 6697.
230 =item B<--ssl>, B<--no-ssl>
232 B<--ssl> enables connecting to the server with SSL, B<--no-ssl> disables this. Defaults to B<--ssl>.
234 =item B<--channel> I<channel>
236 Makes devbot connect to I<channel>. Can be supplied multiple times for multiple channels. Has no default value.
238 =item B<--log>, B<--no-log>
240 B<--log> enables logging events to 'logs/I<CHANNEL>/I<DATE>.txt'. B<--no-log> disables logging. Defaults to B<--log>.
242 =item B<--store-files>, B<--no-store-files>
244 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>.
246 =item B<--trace>, B<--no-trace>
248 B<--trace> enables POE::Component::IRC::State tracing. Useful for debugging. B<--no-trace> disables tracing. Defaults to B<--no-trace>.
254 As stated above, the B<--store-files> option should only be used on private channels where every user is trusted.
258 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
260 =head1 COPYRIGHT AND LICENSE
262 Copyright (C) 2013 by Marius Gavrilescu
264 This library is free software; you can redistribute it and/or modify
265 it under the same terms as Perl itself, either Perl version 5.14.2 or,
266 at your option, any later version of Perl 5 you may have available.
This page took 0.097022 seconds and 3 git commands to generate.