summaryrefslogtreecommitdiffstats
path: root/modules/command.pl
diff options
context:
space:
mode:
authorLibravatarWilliam Heimbigner <william.heimbigner@gmail.com>2012-01-29 07:50:57 +0000
committerLibravatarWilliam Heimbigner <william.heimbigner@gmail.com>2012-01-29 07:50:57 +0000
commitc6d38c7575a09c2b8344857e01a728298148628b (patch)
tree4f56c3e0e8abc71f2de4e0f59ceb37a32a6a1c2b /modules/command.pl
parent471fd83c6e20c9977f5d2271b5c5ce54389dd045 (diff)
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
Diffstat (limited to 'modules/command.pl')
-rw-r--r--modules/command.pl19
1 files changed, 5 insertions, 14 deletions
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";