egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

google.tcl

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
Sanzen
Voice


Joined: 17 Jan 2014
Posts: 12

PostPosted: Wed Jan 28, 2015 11:17 pm    Post subject: google.tcl Reply with quote

I am using the google.tcl that uses the feeling lucky part of google. For some reason it is pulling the first link from google.fr and I am not sure as to why. There is nothing in the code to suggest why it would pull from google.fr unless I am missing something.

Code:
#google.tcl v0.31 - Using the "I'm feeling lucky" button this script returns the best result based on the string you input. Also can return image and regional results. This script is future proof. (Default public commands are !google, !image and !googleuk).
#based on scripts by aNa|0Gue

set google(ver) "0.31"

#Simulate a browser, ie: Mozilla
set google(agent) "MSIE 6.0"

#google search trigger
set google(g_cmd) "!google"

#google uk search trigger
set google(guk_cmd) "!googleuk"

#google image search trigger
set google(gi_cmd) "!image"

#google prefix
set google(prefix) "* Google:"

package require http

bind pub - $google(g_cmd) pub:google
bind pub - $google(guk_cmd) pub:googleuk
bind pub - $google(gi_cmd) pub:image

proc google:go { url arg } {
   global google
   regsub -all " " $arg "+" query
   set lookup "$url$query"
  set token [http::config -useragent $google(agent)]
   set token [http::geturl $lookup]
   puts stderr ""
   upvar #0 $token state
   set max 0
   foreach {name value} $state(meta) {
      if {[regexp -nocase ^location$ $name]} {
         set newurl [string trim $value]
         regsub -all "btnI=&" $url "" url
         if {[regexp {imgres} $newurl]} { set newurl "http://[string range $newurl [expr [string first = $newurl]+1] [expr [string first & $newurl]-1]]" }
         return "$newurl More: $url$query"
      }
   }
}

proc pub:google { nick uhost handle channel arg } {
   global google
   if {[llength $arg]==0} { putserv "NOTICE $nick :Usage: $google(g_cmd) <string>" }
   set url "http://www.google.com/search?btnI=&q="
   set output [google:go $url $arg]
   putserv "PRIVMSG $channel :$nick, $google(prefix) $output"
}

proc pub:googleuk { nick uhost handle channel arg } {
   global google
   set arg "$arg&meta=cr%3DcountryUK%7CcountryGB"
   if {[llength $arg]==0} { putserv "NOTICE $nick :Usage: $google(guk_cmd) <string>" }
   set url "http://www.google.co.uk/search?btnI=&q="
   set output [google:go $url $arg]
   putserv "PRIVMSG $channel :$nick, $google(prefix) $output"
}

proc pub:image { nick uhost handle channel arg } {
   global google
   if {[llength $arg]==0} { putserv "NOTICE $nick :Usage: $google(gi_cmd) <string>" }
   set url "http://images.google.com/images?btnI=&q="
   set output [google:go $url $arg]
   putserv "PRIVMSG $channel :$nick, $google(prefix) $output"
}

putlog "google.tcl $google(ver) loaded"

http://www.egghelp.org/cgi-bin/tcl_archive.tcl?mode=download&id=1711


4 samples of what happens:

Code:
<Sanzen> !google testing
<fubar> Sanzen, * Google: http://www.google.fr/search?btnI=&q=testing&gws_rd=cr&ei=CqbJVOKIAsTharqygfgF More: http://www.google.com/search?q=testing
<Sanzen> !google Eggdrop
<fubar> Sanzen, * Google: http://www.google.fr/search?btnI=&q=Eggdrop&gws_rd=cr&ei=EKbJVIfKENfuaJbQgsgE More: http://www.google.com/search?q=Eggdrop
<Sanzen> !google OnePieceBay
<fubar> Sanzen, * Google: http://www.google.fr/search?btnI=&q=OnePieceBay&gws_rd=cr&ei=HKbJVPfwNJPraOqdgdAE More: http://www.google.com/search?q=OnePieceBay
<Sanzen> !google abs
<fubar> Sanzen, * Google: http://www.google.fr/search?btnI=&q=abs&gws_rd=cr&ei=VJjJVOGjMcz4UP6lgNAG More: http://www.google.com/search?q=abs



edit: I wonder if it could be pulling from google.fr because that is where my server ism thoughts on that?
Back to top
View user's profile Send private message Visit poster's website
Get_A_Fix
Master


Joined: 07 May 2005
Posts: 206
Location: New Zealand

PostPosted: Wed Feb 04, 2015 9:09 am    Post subject: Reply with quote

it's due to the google:go procedure.

Code:

   foreach {name value} $state(meta) {
      if {[regexp -nocase ^location$ $name]} {
         set newurl [string trim $value]
         regsub -all "btnI=&" $url "" url
         if {[regexp {imgres} $newurl]} { set newurl "http://[string range $newurl [expr [string first = $newurl]+1] [expr [string first & $newurl]-1]]" }
         return "$newurl More: $url$query"
      }
   }


That's why the examples show that output format, with 'More:'

Your server is using its local google node, you'd have to either edit out the regex for ^location, or add an if statement to change the URL if string match "*.google.fr*" to replace with *.google.com

Someone will no doubt have a better script, as there are many for google, you may have to try other's, or hope someone can edit yours, or if you can edit it.
_________________
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
CP1832
Halfop


Joined: 09 Oct 2014
Posts: 68

PostPosted: Mon May 30, 2016 6:06 pm    Post subject: Reply with quote

Since the google API is no longer working, this script seems a great alternative. Does anyone know how to show the end result URL instead of the google URL? For instance, http://www.eggheads.org/ instead of http://www.google.fr/search?btnI=&q=Eggdrop&gws_rd=cr&ei=EKbJVIfKENfuaJbQgsgE
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber