]> git.donarmstrong.com Git - infobot.git/commitdiff
* Changes to Google.pl:
authordjmcgrath <djmcgrath@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 2 Dec 2008 21:04:14 +0000 (21:04 +0000)
committerdjmcgrath <djmcgrath@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 2 Dec 2008 21:04:14 +0000 (21:04 +0000)
- Changed referer to be of the format irc://$server/$chan/$nick
- Colorized Google!
- Various WARN/DEBUG/status messages for logging

git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@1854 c11ca15a-4712-0410-83d8-924469b57eb5

src/Modules/Google.pl

index f6762e2ae8994b3920a0a49a3f87b0284a787144..1fab907e866ff0dee3e933edf99eaac177dba958 100644 (file)
@@ -11,22 +11,28 @@ my $maxshow = 5;
 
 sub GoogleSearch {
     my ( $what, $type ) = @_;
-    my $where  = "Google";
+    # $where set to official google colors ;)
+    my $where  = "\00312G\0034o\0038o\00312g\0033l\0034e\003";
     my $retval = "$where can't find \002$what\002";
     my $Search;
+    my $referer = "irc://$::server/$::chan/$::who";
 
     return unless &::loadPerlModule("REST::Google::Search");
 
-    REST::Google::Search->http_referer('http://infobot.sourceforge.net/');
+    &::DEBUG( "Google::GoogleSearch->referer = $referer" );
+    &::status( "Google::GoogleSearch> Searching Google for: $what");
+    REST::Google::Search->http_referer( $referer );
     $Search = REST::Google::Search->new( q => $what );
 
     if ( !defined $Search ) {
         &::msg( $::who, "$where is invalid search." );
+        &::WARN( "Google::GoogleSearch> $::who generated an invalid search: $where");
         return;
     }
 
     if ( $Search->responseStatus != 200 ) {
         &::msg( $::who, "http error returned." );
+        &::WARN( "Google::GoogleSearch> http error returned: $Search->responseStatus");
         return;
     }
 
@@ -35,10 +41,10 @@ sub GoogleSearch {
     my @results = $data->results;
 
     my $count;
-    $retval = "$where says \002$what\002 is at ";
+    $retval = "$where says \"\002$what\002\" is at ";
     foreach my $r (@results) {
         my $url = $r->url;
-        $retval .= ' or ' if ( $count > 0 );
+        $retval .= " \002or\002 " if ( $count > 0 );
         $retval .= $url;
         last if ++$count >= $maxshow;
     }