]> git.donarmstrong.com Git - infobot.git/blobdiff - src/CommandStubs.pl
&showProc in delForked()
[infobot.git] / src / CommandStubs.pl
index d63ae74359b992b48b7941d5972f16d85099536f..fbe42582e10e6dc8504b9aa596a36241f2c78b2d 100644 (file)
@@ -4,10 +4,6 @@
 
 if (&IsParam("useStrict")) { use strict; }
 
-use vars qw(@W3Search_engines $W3Search_regex);
-@W3Search_engines = qw(AltaVista Dejanews Excite Gopher HotBot Infoseek
-                       Lycos Magellan PLweb SFgate Simple Verity Google);
-$W3Search_regex = join '|', @W3Search_engines;
 $babel::lang_regex = "";       # lame fix.
 
 ### PROPOSED COMMAND HOOK IMPLEMENTATION.
@@ -31,22 +27,22 @@ sub addCmdHook {
 
 # RUN IF ADDRESSED.
 sub parseCmdHook {
-    my @args = split(' ', $message);
+    my @args   = split(' ', $message);
+    my $cmd    = shift(@args);
 
     &shmFlush();
 
     foreach (keys %cmdhooks) {
        my $ident = $_;
 
-       next unless ($args[0] =~ /^$ident$/i);
-       shift(@args);   # just gotta do it.
+       next unless ($cmd =~ /^$ident$/i);
 
-       &DEBUG("pCH: found $ident");
+       &DEBUG("pCH: $cmd matched $ident");
        my %hash = %{ $cmdhooks{$ident} };
 
        ### DEBUG.
        foreach (keys %hash) {
-           &DEBUG(" $ident->$_ => '$hash{$_}'.");
+           &DEBUG(" $cmd->$_ => '$hash{$_}'.");
        }
 
        ### HELP.
@@ -70,7 +66,9 @@ sub parseCmdHook {
 
            ### TODO: check if CODEREF exists.
 
-           &{$hash{'CODEREF'}}(@args);
+### ANY PROBLEMS WITH THIS? if so, add option to do either.
+###        &{$hash{'CODEREF'}}(@args);
+           &{$hash{'CODEREF'}}(join ' ', @args);
        }
 
        ### CMDSTATS.
@@ -142,10 +140,11 @@ sub parseCmdHook {
 &addCmdHook('uptime', ('CODEREF' => 'uptime', 'Identifier' => 'uptime',
        'Cmdstats' => 'Uptime') );
 &addCmdHook('nullski', ('CODEREF' => 'nullski', ) );
+&addCmdHook('crash', ('CODEREF' => 'crash' ) );
 sub nullski { my ($arg) = @_; foreach (`$arg`) { &msg($who,$_); } }
-&addCmdHook('freshmeat', ('CODEREF' => 'Freshmeat::Freshmeat',
+&addCmdHook('(fm|freshmeat)', ('CODEREF' => 'Freshmeat::Freshmeat',
        'Identifier' => 'freshmeat', 'Cmdstats' => 'Freshmeat',
-       'Module' => 'freshmeat', 'Help' => 'freshmeat') );
+       'Forker' => 1, 'Help' => 'freshmeat') );
 
 
 
@@ -194,10 +193,10 @@ sub Modules {
     }
 
     # google searching. Simon++
-    if (&IsParam("wwwsearch") and $message =~ /^(?:search\s+)?($W3Search_regex)\s+for\s+['"]?(.*?)['"]?\s*\?*$/i) {
+    if (&IsParam("wwwsearch") and $message =~ /^(?:search\s+)?(\S+)\s+for\s+['"]?(.*?)['"]?\s*\?*$/i) {
        return $noreply unless (&hasParam("wwwsearch"));
 
-       &Forker("wwwsearch", sub { &W3Search::W3Search($1,$2,$param{'wwwsearch'}); } );
+       &Forker("wwwsearch", sub { &W3Search::W3Search($1,$2); } );
 
        $cmdstats{'WWWSearch'}++;
        return $noreply;
@@ -483,12 +482,13 @@ sub cookie {
 }
 
 sub convert {
-    my (@args) = @_;
-    my ($from,$to);
-    ($from,$to) = ($args[0],$args[2]) if ($args[1] =~ /^from$/i);
-    ($from,$to) = ($args[2],$args[0]) if ($args[1] =~ /^to$/i);
+    my $arg = join(' ',@_);
+    my ($from,$to) = ('','');
 
-    if (!defined $from or !defined $to or $to eq "" or $from eq "") {
+    ($from,$to) = ($1,$2) if ($arg =~ /^(.*?) to (.*)$/i);
+    ($from,$to) = ($2,$1) if ($arg =~ /^(.*?) from (.*)$/i);
+
+    if (!$to or !$from) {
        &msg($who, "Invalid format!");
        &help("convert");
        return $noreply;