Permalink
Browse files

Make parsed arguments avalaible in Auth_sub.

  • Loading branch information...
1 parent 4989ac9 commit 7c53d62bb0cc15ca9899fe14b1403930ac8ef72b @okxchg okxchg committed Jun 2, 2012
Showing with 16 additions and 14 deletions.
  1. +16 −14 lib/POE/Component/IRC/Plugin/BotCommand.pm
View
30 lib/POE/Component/IRC/Plugin/BotCommand.pm
@@ -106,20 +106,6 @@ sub _handle_cmd {
my $public = $where =~ /^[$chantypes]/ ? 1 : 0;
$cmd = lc $cmd;
- if (ref $self->{Auth_sub} eq 'CODE') {
- my ($authed, $errors) = $self->{Auth_sub}->($self->{irc}, $who, $where, $cmd, $args);
-
- if (!$authed) {
- my @errors = ref $errors eq 'ARRAY'
- ? @$errors
- : 'You are not authorized to use this command.';
- for my $error (@errors) {
- $irc->yield($self->{Method}, $where, $error);
- }
- return;
- }
- }
-
if (defined $self->{Commands}->{$cmd}) {
if (ref $self->{Commands}->{$cmd} eq 'HASH') {
my @args_array = defined $args ? split /\s+/, $args : ();
@@ -134,7 +120,23 @@ sub _handle_cmd {
$args->{$_} = shift @args_array;
}
}
+ }
+
+ if (ref $self->{Auth_sub} eq 'CODE') {
+ my ($authed, $errors) = $self->{Auth_sub}->($self->{irc}, $who, $where, $cmd, $args);
+
+ if (!$authed) {
+ my @errors = ref $errors eq 'ARRAY'
+ ? @$errors
+ : 'You are not authorized to use this command.';
+ for my $error (@errors) {
+ $irc->yield($self->{Method}, $where, $error);
+ }
+ return;
+ }
+ }
+ if (defined $self->{Commands}->{$cmd}) {
$irc->send_event_next("irc_botcmd_$cmd" => $who, $where, $args);
}
elsif ($cmd =~ /^help$/i) {

0 comments on commit 7c53d62

Please sign in to comment.