X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2FFactoids%2FQuestion.pl;fp=src%2FFactoids%2FQuestion.pl;h=1b4d823847ada1b31123da7b70559e215786fab0;hb=20440d642f070b3edbba2bf7eff9d4f37d1cd86b;hp=3fdccee7aa06fe6ffaae23cce76db205828c0f26;hpb=80577669c1c6f0f8f9cda0292b0dd21a98e86de7;p=infobot.git diff --git a/src/Factoids/Question.pl b/src/Factoids/Question.pl index 3fdccee..1b4d823 100644 --- a/src/Factoids/Question.pl +++ b/src/Factoids/Question.pl @@ -103,7 +103,7 @@ sub doQuestion { push( @query, $query ) if ( $query ne $x ); if ( &IsChanConf('factoidArguments') > 0 ) { - $result = &factoidArgs( $query[0] ); + $result = &factoidArgs( $query[0] , $chan); return $result if ( defined $result ); } @@ -194,9 +194,11 @@ sub doQuestion { } sub factoidArgs { - my ($str) = @_; + my ($str,$chan) = @_; my $result; + $chan //= ''; + # to make it eleeter, split each arg and use "blah OR blah or BLAH" # which will make it less than linear => quicker! # TODO: cache this, update cache when altered. !!! !!! !!! @@ -206,11 +208,14 @@ sub factoidArgs { # ignore split to commands [dumb commands vs. factoids] (editing commands?) return undef if $str =~ /\s+\=\~\s+s[\#\/\:]/; my @list = + &searchTable( 'factoids', 'factoid_key', 'factoid_key', "^$chan cmd: $first " ); &searchTable( 'factoids', 'factoid_key', 'factoid_key', "^cmd: $first " ); + &DEBUG("chan is $chan, first is $first; searching for '^$chan cmd: $first' "); + # my $delta_time = &timedelta($t); # &DEBUG("factArgs: delta_time = $delta_time s"); - # &DEBUG("factArgs: list => ".scalar(@list) ); + &DEBUG("factArgs: list => ".scalar(@list) ); # from a design perspective, it's better to have the regex in # the factoid key to reduce repetitive processing.