diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 6605e2e..668e010 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -3,6 +3,8 @@ Auto IRC Bot 3.0: Change Log 3.0 Indev ================================================================== + * Fixed a bug in API::Log that caused invalid months. + * Changed how command data is passed to fix a bug. * Removed dependency Async. * Rewrote the socket engine. * Added cmd_add|del|run() to API::Std for commands. diff --git a/src/API/Log.pm b/src/API/Log.pm index 3e621d6..cd80330 100644 --- a/src/API/Log.pm +++ b/src/API/Log.pm @@ -92,6 +92,7 @@ sub expire_logs # Convert filename to UNIX time. my $yyyy = substr($file, 0, 4); my $mm = substr($file, 4, 2); + $mm = $mm - 1; my $dd = substr($file, 6, 2); my $epoch = timelocal(0, 0, 0, $dd, $mm, $yyyy); diff --git a/src/API/Std.pm b/src/API/Std.pm index 14006fc..ccd06f0 100644 --- a/src/API/Std.pm +++ b/src/API/Std.pm @@ -123,21 +123,6 @@ sub cmd_del return 1; } -# Run a command if it exists. -sub cmd_run -{ - my ($cmd, $lvl, %src, @argv) = @_; - $cmd = uc($cmd); - - return 0 if (!defined $CMDS{$cmd}); - - if ($CMDS{$cmd}{lvl} == $lvl or $CMDS{$cmd}{lvl} == 2) { - &{ $CMDS{$cmd}{sub} }(%src, @argv); - } - - return 1; -} - # Add an event to Auto. sub event_add { diff --git a/src/Parser/IRC.pm b/src/Parser/IRC.pm index 3bcc674..ebd26ce 100644 --- a/src/Parser/IRC.pm +++ b/src/Parser/IRC.pm @@ -339,26 +339,37 @@ sub nick sub privmsg { my ($svr, @ex) = @_; - my %src = API::IRC::usrc(substr($ex[0], 1)); + my %data = API::IRC::usrc(substr($ex[0], 1)); - my $cprefix = (conf_get("fantasy_pf"))[0][0]; - my $rprefix = substr($ex[3], 1, 1); - my $cmd = uc(substr($ex[3], 2)); - my (@argv); + my @argv; for (my $i = 4; $i < scalar(@ex); $i++) { push(@argv, $ex[$i]); } - $src{svr} = $svr; + $data{svr} = $svr; + @{ $data{args} } = @argv; + my ($cmd, $cprefix, $rprefix); # Check if it's to a channel or to us. if (lc($ex[2]) eq lc($botnick{$svr}{nick})) { # It is coming to us in a private message. - API::Std::cmd_run($cmd, 1, %src, @argv); + $cmd = uc(substr($ex[3], 1)); + if (defined $API::Std::CMDS{$cmd}) { + if ($API::Std::CMDS{$cmd}{lvl} == 1 or $API::Std::CMDS{$cmd}{lvl} == 2) { + &{ $API::Std::CMDS{$cmd}{sub} }(%data) if $rprefix eq $cprefix; + } + } } else { # It is coming to us in a channel message. - $src{chan} = $ex[2]; - API::Std::cmd_run($cmd, 0, %src, @argv); + $data{chan} = $ex[2]; + $cprefix = (conf_get("fantasy_pf"))[0][0]; + $rprefix = substr($ex[3], 1, 1); + $cmd = uc(substr($ex[3], 2)); + if (defined $API::Std::CMDS{$cmd}) { + if ($API::Std::CMDS{$cmd}{lvl} == 0 or $API::Std::CMDS{$cmd}{lvl} == 2) { + &{ $API::Std::CMDS{$cmd}{sub} }(%data) if $rprefix eq $cprefix; + } + } } return 1;