mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 13:59:47 +01:00
Check commands table for keyword before searching regexs
This commit is contained in:
parent
d8c12522ed
commit
17afac5908
@ -74,6 +74,16 @@ sub unregister_by_name {
|
||||
@{ $self->{handlers} } = grep { $_->{name} ne $name } @{ $self->{handlers} };
|
||||
}
|
||||
|
||||
sub exists {
|
||||
my $self = shift;
|
||||
my ($keyword) = @_;
|
||||
|
||||
foreach my $ref (@{ $self->{handlers} }) {
|
||||
return 1 if $ref->{name} eq $keyword;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub interpreter {
|
||||
my $self = shift;
|
||||
my ($from, $nick, $user, $host, $depth, $keyword, $arguments, $tonick) = @_;
|
||||
|
@ -252,6 +252,10 @@ sub find_factoid {
|
||||
|
||||
my @result = eval {
|
||||
for (my $depth = 0; $depth < 5; $depth++) {
|
||||
if ($self->{pbot}->{commands}->exists($keyword)) {
|
||||
return undef;
|
||||
}
|
||||
|
||||
# check factoids
|
||||
foreach my $channel (sort keys %{ $self->{factoids}->hash }) {
|
||||
if($exact_channel) {
|
||||
@ -483,7 +487,6 @@ sub interpreter {
|
||||
|
||||
while ($action =~ /(?<!\\)\$([a-zA-Z0-9_\-]+)/g) {
|
||||
my $v = $1;
|
||||
print "v = [$v]\n";
|
||||
next if $v =~ m/^[0-9]+$/;
|
||||
my ($var_chan, $var) = $self->find_factoid($from, $v, undef, 0, 1);
|
||||
|
||||
@ -498,7 +501,7 @@ sub interpreter {
|
||||
$mylist[$line] =~ s/"//g;
|
||||
$action =~ s/\$$var/$mylist[$line]/;
|
||||
} else {
|
||||
$action =~ s/\$$var/$var/g;
|
||||
$action =~ s/(?<!\\)\$$var/$var/;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -222,6 +222,7 @@ sub handle_result {
|
||||
|
||||
if (defined $command) {
|
||||
my ($cmd, $args) = split / /, $command, 2;
|
||||
if (not $self->{pbot}->{commands}->exists($cmd)) {
|
||||
my ($chan, $trigger) = $self->{pbot}->{factoids}->find_factoid($from, $cmd, $args, 0, 0, 1);
|
||||
if(defined $trigger) {
|
||||
if ($preserve_whitespace == 0) {
|
||||
@ -233,6 +234,7 @@ sub handle_result {
|
||||
$use_output_queue = 0 if not defined $use_output_queue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $preserve_newlines = $self->{pbot}->{registry}->get_value($from, 'preserve_newlines');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user