]> git.donarmstrong.com Git - infobot.git/commitdiff
- tell: command redirection added.
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Fri, 2 Feb 2001 13:12:26 +0000 (13:12 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Fri, 2 Feb 2001 13:12:26 +0000 (13:12 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@302 c11ca15a-4712-0410-83d8-924469b57eb5

blootbot/src/UserExtra.pl

index 24fbb065d36a910478a7c43c1cd5099f4f6ad4ac..6d693e350ceeb1528fdb994db97f5bdc6009709a 100644 (file)
@@ -294,7 +294,7 @@ sub tell {
     $target    = $talkchannel  if ($target =~ /^us$/i);
     $target    = $who          if ($target =~ /^(me|myself)$/i);
 
-    &status("target: $target query: $query");  
+    &status("tell: target = $target, query = $query");  
 
     # "intrusive".
     if ($target !~ /^$mask{chan}$/ and !&IsNickInAnyChan($target)) {
@@ -312,20 +312,43 @@ sub tell {
 
     # ...
     my $result = &doQuestion($tell_obj);
-    &DEBUG("result => $result.");
-#    return if ($result eq);
+    # ^ returns '0' if nothing was found.
 
     # no such factoid.
-    if ($result eq "") {
-       &msg($who, "i dunno what is '$tell_obj'.");
+    if ($result =~ /^0?$/) {
+       my $oldwho      = $who;
+       my $oldmtype    = $msgType;
+       $who            = $target;
+       $msgType        = "private";
+
+       # support command redirection.
+       # recursive cmdHooks aswell :)
+       my $done = 0;
+       $done++ if &parseCmdHook("main", $tell_obj);
+       $done++ if &parseCmdHook("extra", $tell_obj);
+
+       &DEBUG("setting old values of who and msgType.");
+       $who            = $oldwho;
+       $msgType        = $oldmtype;
+
+       if ($done) {
+           &msg($who, "told $target about CMD '$tell_obj'");
+       } else {
+           &msg($who, "i dunno what is '$tell_obj'.");
+       }
+
        return;
     }
 
     # success.
     &status("tell: <$who> telling $target about $tell_obj.");
     if ($who ne $target) {
-       &msg($who, "told $target about $tell_obj ($result)")
-                                               unless ($dont_tell_me);
+       if ($dont_tell_me) {
+           &msg($who, "told $target about $tell_obj.");
+       } else {
+           &msg($who, "told $target about $tell_obj ($result)");
+       }
+
        $reply = "$who wants you to know: $result";
     } else {
        $reply = "telling yourself: $result";