blob: c1f93ef30d9c93175bfb520f81ef126c44aad0fc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
package ASM::Commander;
use warnings;
use strict;
use IO::All;
use POSIX qw(strftime);
use Data::Dumper;
use URI::Escape;
sub new
{
my $module = shift;
my $self = {};
bless($self);
return $self;
}
sub command
{
my ($self, $conn, $event) = @_;
my $args = $event->{args}->[0];
my $from = $event->{from};
my $cmd = $args;
my $d1;
my $nick = lc $event->{nick};
my $acct;
if (defined($::sn{$nick}) && defined($::sn{$nick}->{account})) {
$acct = lc $::sn{$nick}->{account};
}
# return 0 unless (ASM::Util->speak($event->{to}->[0]));
foreach my $command ( @{$::commands->{command}} )
{
my $fail = 0;
unless ( (ASM::Util->speak($event->{to}->[0])) ) {
next unless (defined($command->{nohush}) && ($command->{nohush} eq "nohush"));
}
if (defined($command->{flag})) { #If the command is restricted,
if (!defined($acct)) {
$fail = 1;
}
elsif (!defined($::users->{person}->{$acct})) { #make sure the requester has an account
$fail = 1;
}
elsif (!defined($::users->{person}->{$acct}->{flags})) { #make sure the requester has flags defined
$fail = 1;
}
elsif (!(grep {$_ eq $command->{flag}} split('', $::users->{person}->{$acct}->{flags}))) { #make sure the requester has the needed flags
$fail = 1;
}
}
if ($cmd=~/$command->{cmd}/) {
ASM::Util->dprint("$event->{from} told me: $cmd", "commander");
if (!ASM::Util->notRestricted($nick, "nocommands")) {
$fail = 1;
}
if ($fail == 1) {
$conn->privmsg($nick, "You don't have permission to use that command, or you're not signed into nickserv.");
} else {
eval $command->{content};
warn $@ if $@;
}
last;
}
}
}
1;
|