blob: 889a3deaeac41351cf39a5c1362820f0ee565ab1 (
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
|
package ASM::Commander;
use warnings;
use strict;
use IO::All;
use POSIX qw(strftime);
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};
# 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 ($cmd=~/$command->{cmd}/) {
print strftime("%F %T ", gmtime) . "$event->{from} told me: $cmd \n";
eval $command->{content};
warn $@ if $@;
last;
}
}
}
1;
|