]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Modules/W3Search.pl
single line for now
[infobot.git] / src / Modules / W3Search.pl
index 8f216b808aee93796022f0aac91b8b7c25eb5da3..a74cf993c4581e6faa9bdfc433dd74b4137049d0 100644 (file)
@@ -7,7 +7,7 @@ package W3Search;
 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);
+               Lycos Magellan PLweb SFgate Simple Verity Google z);
 $W3Search_regex = join '|', @W3Search_engines;
 
 my $maxshow    = 3;
@@ -15,21 +15,27 @@ my $maxshow = 3;
 sub W3Search {
     my ($where, $what, $type) = @_;
     my $retval = "$where can't find \002$what\002";
-
-    return unless &::loadPerlModule("WWW::Search");
-
-    if (defined $type) {
-       &::DEBUG("W3S: type => $type");
-    }
+    my $Search;
 
     my @matches = grep { lc($_) eq lc($where) ? $_ : undef } @W3Search_engines;
     if (@matches) {
        $where = shift @matches;
     } else {
        &::msg($::who, "i don't know how to check '$where'");
+       return;
+    }
+
+    return unless &::loadPerlModule("WWW::Search");
+
+    eval {
+       $Search = new WWW::Search($where);
+    };
+
+    if (!defined $Search) {
+       &::msg($::who, "$where is invalid search.");
+       return;
     }
 
-    my $Search = new WWW::Search($where);
     my $Query  = WWW::Search::escape_query($what);
     $Search->native_query($Query,
 #      {