]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Modules/Google.pl
* Google module should now return a URI as is, without converting chars that could...
[infobot.git] / src / Modules / Google.pl
index 1fab907e866ff0dee3e933edf99eaac177dba958..41187a6d33a5a59ddb6bc0089ef1765f24fbf944 100644 (file)
@@ -36,17 +36,29 @@ sub GoogleSearch {
         return;
     }
 
+    # No results found
+    if ( not $Search->responseData->results ) {
+        &::DEBUG( "Google::GoogleSearch> $retval" );
+        &::msg( $::who, $retval);
+        return;
+    }
+
     my $data    = $Search->responseData;
     my $cursor  = $data->cursor;
     my @results = $data->results;
-
     my $count;
+
     $retval = "$where says \"\002$what\002\" is at ";
     foreach my $r (@results) {
         my $url = $r->url;
+
+        # Returns a string with each %XX sequence replaced with the actual byte
+        # (octet). From URI::Escape uri_unescape()
+        $url =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
+
         $retval .= " \002or\002 " if ( $count > 0 );
         $retval .= $url;
-        last if ++$count >= $maxshow;
+        last if ++$count >= $maxshow; # Only seems to return max of 4?
     }
 
     &::performStrictReply($retval);