From c6d38c7575a09c2b8344857e01a728298148628b Mon Sep 17 00:00:00 2001 From: William Heimbigner Date: Sun, 29 Jan 2012 07:50:57 +0000 Subject: State tracking of user accounts, use freenode's CAP features to avoid whois'ing users and improve access control for bot's commands, remove some dead code --- modules/command.pl | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'modules/command.pl') diff --git a/modules/command.pl b/modules/command.pl index 889a3de..ded53a5 100644 --- a/modules/command.pl +++ b/modules/command.pl @@ -20,26 +20,17 @@ sub command my $cmd = $args; my $d1; my $nick = lc $event->{nick}; + my $acct = lc $::sn{$nick}->{account}; # return 0 unless (ASM::Util->speak($event->{to}->[0])); foreach my $command ( @{$::commands->{command}} ) { unless (ASM::Util->speak($event->{to}->[0])) { next unless (defined($command->{nohush}) && ($command->{nohush} eq "nohush")); } - if (defined($command->{flag})) { - next unless defined($::users->{person}->{$nick}); - next unless defined($::users->{person}->{$nick}->{flags}); - next unless (grep {$_ eq $command->{flag}} split('', $::users->{person}->{$nick}->{flags})); - if ($::users->{person}->{$nick}->{host} ne 'IDENTIFY') { - next unless (lc $::users->{person}->{$nick}->{host} eq lc $event->{host}); - } - else { - if ( $cmd =~ /$command->{cmd}/ ){ - push (@{$::idqueue{$nick}}, [$cmd, $command, $event]); - $conn->sl("whois $nick $nick"); - last; - } - } + if (defined($command->{flag})) { #If the command is restricted, + next unless defined($::users->{person}->{$acct}); #make sure the requester has an account + next unless defined($::users->{person}->{$acct}->{flags}); #make sure the requester has flags defined + next unless (grep {$_ eq $command->{flag}} split('', $::users->{person}->{$acct}->{flags})); #make sure the requester has the needed flags } if ($cmd=~/$command->{cmd}/) { print strftime("%F %T ", gmtime) . "$event->{from} told me: $cmd \n"; -- cgit v1.2.3