mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-25 19:44:26 +01:00
Fix regex factoids so that regular factoid keywords have priority over regex triggers
This commit is contained in:
parent
f70e044a60
commit
f640ade74e
@ -249,22 +249,34 @@ sub find_factoid {
|
|||||||
$self->{pbot}->{logger}->log("string: $string\n") if $debug;
|
$self->{pbot}->{logger}->log("string: $string\n") if $debug;
|
||||||
|
|
||||||
my @result = eval {
|
my @result = eval {
|
||||||
|
# check factoids
|
||||||
foreach my $channel (sort keys %{ $self->{factoids}->hash }) {
|
foreach my $channel (sort keys %{ $self->{factoids}->hash }) {
|
||||||
if($exact_channel) {
|
if($exact_channel) {
|
||||||
next unless $from eq lc $channel or $channel eq '.*';
|
next unless $from eq lc $channel or $channel eq '.*';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $trigger (keys %{ $self->{factoids}->hash->{$channel} }) {
|
foreach my $trigger (keys %{ $self->{factoids}->hash->{$channel} }) {
|
||||||
if(not $exact_trigger and $self->{factoids}->hash->{$channel}->{$trigger}->{type} eq 'regex') {
|
if($keyword =~ m/^\Q$trigger\E$/i) {
|
||||||
$self->{pbot}->{logger}->log("checking regex $string =~ m/$trigger/i\n") if $debug;
|
$self->{pbot}->{logger}->log("return $channel: $trigger\n") if $debug;
|
||||||
if($string =~ m/$trigger/i) {
|
return ($channel, $trigger);
|
||||||
$self->{pbot}->{logger}->log("return regex $channel: $trigger\n") if $debug;
|
}
|
||||||
return ($channel, $trigger);
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if($keyword =~ m/^\Q$trigger\E$/i) {
|
# then check regex factoids
|
||||||
$self->{pbot}->{logger}->log("return $channel: $trigger\n") if $debug;
|
if(not $exact_trigger) {
|
||||||
return ($channel, $trigger);
|
foreach my $channel (sort keys %{ $self->{factoids}->hash }) {
|
||||||
|
if($exact_channel) {
|
||||||
|
next unless $from eq lc $channel or $channel eq '.*';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $trigger (keys %{ $self->{factoids}->hash->{$channel} }) {
|
||||||
|
if($self->{factoids}->hash->{$channel}->{$trigger}->{type} eq 'regex') {
|
||||||
|
$self->{pbot}->{logger}->log("checking regex $string =~ m/$trigger/i\n") if $debug;
|
||||||
|
if($string =~ m/$trigger/i) {
|
||||||
|
$self->{pbot}->{logger}->log("return regex $channel: $trigger\n") if $debug;
|
||||||
|
return ($channel, $trigger);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ use warnings;
|
|||||||
# These are set automatically by the build/commit script
|
# These are set automatically by the build/commit script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 794,
|
BUILD_REVISION => 795,
|
||||||
BUILD_DATE => "2014-10-13",
|
BUILD_DATE => "2014-10-28",
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user