From 20440d642f070b3edbba2bf7eff9d4f37d1cd86b Mon Sep 17 00:00:00 2001 From: dondelelcaro Date: Thu, 6 Mar 2014 20:28:49 +0000 Subject: [PATCH] use chan in factargs search git-svn-id: https://svn.code.sf.net/p/infobot/code/branches/don/dpkg@1935 c11ca15a-4712-0410-83d8-924469b57eb5 --- src/Factoids/Question.pl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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. -- 2.39.2