]> git.donarmstrong.com Git - infobot.git/commitdiff
use chan in factargs search
authordondelelcaro <dondelelcaro@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 6 Mar 2014 20:28:49 +0000 (20:28 +0000)
committerdondelelcaro <dondelelcaro@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 6 Mar 2014 20:28:49 +0000 (20:28 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/branches/don/dpkg@1935 c11ca15a-4712-0410-83d8-924469b57eb5

src/Factoids/Question.pl

index 3fdccee7aa06fe6ffaae23cce76db205828c0f26..1b4d823847ada1b31123da7b70559e215786fab0 100644 (file)
@@ -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.