From: timriker Date: Thu, 17 Feb 2005 03:04:07 +0000 (+0000) Subject: wtf forker hacked up from jethro's patch X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f14fc699c27b28da91f897dda82ea300cc741407;p=infobot.git wtf forker hacked up from jethro's patch git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@1128 c11ca15a-4712-0410-83d8-924469b57eb5 --- diff --git a/blootbot/files/blootbot.help b/blootbot/files/blootbot.help index 218eb1a..790c813 100644 --- a/blootbot/files/blootbot.help +++ b/blootbot/files/blootbot.help @@ -423,6 +423,10 @@ wikipedia: U: ## wikipedia: U: wiki wikipedia: E: wiki irc +wtf: D: Interface to the BSD wtf command +wtf: U: ## +wtf: E: ## iirc + -host: D: admin command to remove hostmask from a user account -host: U: ## [user] -host: E: ## *!*@owns.org diff --git a/blootbot/files/sample/blootbot.chan b/blootbot/files/sample/blootbot.chan index 0d496b0..e868c79 100644 --- a/blootbot/files/sample/blootbot.chan +++ b/blootbot/files/sample/blootbot.chan @@ -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 diff --git a/blootbot/src/CommandStubs.pl b/blootbot/src/CommandStubs.pl index 0f2c5c8..92793e7 100644 --- a/blootbot/src/CommandStubs.pl +++ b/blootbot/src/CommandStubs.pl @@ -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/blootbot/src/Modules/wtf.pl b/blootbot/src/Modules/wtf.pl new file mode 100644 index 0000000..79fee7f --- /dev/null +++ b/blootbot/src/Modules/wtf.pl @@ -0,0 +1,53 @@ +# +# wtf.pl: interface to bsd wtf +# Author: Tim Riker +# 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 ."); + } + 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