]> git.donarmstrong.com Git - infobot.git/commitdiff
wtf forker hacked up from jethro's patch
authortimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 17 Feb 2005 03:04:07 +0000 (03:04 +0000)
committertimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 17 Feb 2005 03:04:07 +0000 (03:04 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@1128 c11ca15a-4712-0410-83d8-924469b57eb5

files/blootbot.help
files/sample/blootbot.chan
src/CommandStubs.pl
src/Modules/wtf.pl [new file with mode: 0644]

index 218eb1aaeca63b8a31d78fe1866683fd5ded982a..790c813860374ed2a94c14fbaa623eea1f3f198b 100644 (file)
@@ -423,6 +423,10 @@ wikipedia: U: ## <topic>
 wikipedia: U: wiki <topic>
 wikipedia: E: wiki irc
 
+wtf: D: Interface to the BSD wtf command
+wtf: U: ## <abbreviation>
+wtf: E: ## iirc
+
 -host: D: admin command to remove hostmask from a user account
 -host: U: ## [user] <mask>
 -host: E: ## *!*@owns.org
index 0d496b0d312591576a08cdbb356a94c683af63bf..e868c79adbf79743f8ba77e0b4db4a325ef9af4a 100644 (file)
@@ -1,4 +1,4 @@
-#v1: blootbot -- blootbot -- written Thu Dec  9 21:27:25 2004
+#v1: blootbot -- infobot -- written Thu Feb 17 02:56:42 2005
 
 #botpark
     +RootWarn
@@ -79,6 +79,7 @@ _default
     +slashdot
     +spell
     +tell
+    +wtf
     +zfi
     +zsi
 
index 0f2c5c86b579bf3614f8d2351a3cea9029f8cdbc..92793e738d0b1bbf54df9ecc01400e620509fdb7 100644 (file)
@@ -274,6 +274,9 @@ sub parseCmdHook {
 &addCmdHook("extra", '(babel(fish)?|x|xlate|translate)', ('CODEREF' => 'babelfish::babelfish',
        'Identifier' => 'babelfish', 'Cmdstats' => 'babelfish',
        'Forker' => 1, 'Help' => 'babelfish') );
+&addCmdHook("extra", 'wtf', ('CODEREF' => 'wtf::query',
+       'Identifier' => 'wtf', 'Cmdstats' => 'wtf',
+       'Forker' => 1, 'Help' => 'wtf') );
 ###
 ### END OF ADDING HOOKS.
 ###
diff --git a/src/Modules/wtf.pl b/src/Modules/wtf.pl
new file mode 100644 (file)
index 0000000..79fee7f
--- /dev/null
@@ -0,0 +1,53 @@
+#
+#     wtf.pl: interface to bsd wtf
+#     Author: Tim Riker <Tim@Rikers.org>
+#     Source: modified from jethro's patch
+#  Licensing: Artistic License (as perl itself)
+#    Version: v0.1
+#
+#  Copyright (c) 2005 Tim Riker
+#
+
+package wtf;
+
+use strict;
+
+sub wtf::wtf {
+       my $query = shift;
+       my $binary;
+       my @binaries = (
+               '/usr/games/wtf',
+               '/usr/local/bin/wtf'
+       );
+       foreach (@binaries) {
+               if (-x $_) {
+                       $binary=$_;
+                       last;
+               }
+       }
+       if (!$binary) {
+               return("no binary found.");
+       }
+       if ($query =~ /^$|[^\w]/){
+               return("usage: wtf <foo>.");
+       }
+       if (!&main::validExec($query)) {
+               return("argument appears to be fuzzy.");
+       }
+
+       my $reply ="";
+       foreach (`$binary '$query' 2>&1`){
+               $reply .= $_;
+       }
+       $reply =~ s/\n/ /;
+       chomp($reply);
+       return($reply);
+}
+
+sub wtf::query {
+       &::performStrictReply(&wtf(@_));
+       return;
+}
+
+1;
+# vim: ts=2 sw=2