diff --git a/PBot/Factoids.pm b/PBot/Factoids.pm index 0ba1fbbb..eb5f5e2b 100644 --- a/PBot/Factoids.pm +++ b/PBot/Factoids.pm @@ -269,7 +269,7 @@ sub find_factoid { # check factoids foreach my $channel (sort keys %{ $self->{factoids}->hash }) { if($exact_channel) { - if($exact_trigger) { + if($exact_trigger == 1) { next unless $from eq lc $channel; } else { next unless $from eq lc $channel or $channel eq '.*'; @@ -291,7 +291,7 @@ sub find_factoid { goto NEXT_DEPTH; } - if ($exact_channel) { + if ($exact_channel == 1) { return ($channel, $trigger); } else { push @results, [$channel, $trigger]; @@ -320,7 +320,7 @@ sub find_factoid { goto NEXT_DEPTH; } - if ($exact_channel) { + if ($exact_channel == 1) { return ($channel, $trigger); } else { push @results, [$channel, $trigger]; @@ -358,14 +358,19 @@ sub expand_factoid_vars { while ($action =~ /(?find_factoid($from, $v, undef, 0, 1); + if ($modifier =~ m/^:(#.*|global)$/i) { + $from = $1; + $from = '.*' if lc $from eq 'global'; + } + + my @factoids = $self->find_factoid($from, $v, undef, 2, 2); next if not @factoids or not $factoids[0]; my ($var_chan, $var) = ($factoids[0]->[0], $factoids[0]->[1]);