| View previous topic :: View next topic |
| Author |
Message |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Wed Feb 23, 2005 12:33 pm Post subject: google script without package http |
|
|
I looked around a bit, but all script I found where using the lib http which functions tend to crash my windrop. I have noticed using egghttp is save for me, so I wonder if there is any based on this one? either way I'd have to do it myself again @_o. _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
^DooM^ Owner

Joined: 26 Aug 2003 Posts: 772 Location: IronForge
|
Posted: Wed Feb 23, 2005 2:16 pm Post subject: |
|
|
The only google script i found that actually worked uses
| Code: | | package require http |
I can send it you if you wish tho. _________________ The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Wed Feb 23, 2005 11:55 pm Post subject: |
|
|
and thats exakt the kind useless for me, because the package http (avaible under lib/tcl8.4/http2.5) is useless for me, it crachs (more or less randomly. one day it will crash on query xy, next week on yz @_o), dont ask me why... I believe its a problem with cygwin and tcl (but seems noone on windrop.sourceforge.com knows any more, either). I guess I'll have to rewrite it to egghttp myself, I hoped I could spare the work .
| Code: | # De Kus' google port from http to egghttp
#
# 1.0.0 24.02.2005 rewrote done
#
# following orignal header:
#
# google.tcl v0.2.1
#
# !google keywords - displays the first related website found from google in the channel
# !image keywords - displays the first related image found on google in the channel
# !file keywords - displays the first mirror download link found on filemirrors in the channel
#
# by aNa|0Gue - analogue@glop.org - http://www.glop.org/
#
# 04/17/2002 v0.2.1 useragent fix by FAN
if { ![info exists egghttp(version)] } {
putlog "Could not verify egghttp.tcl beeing loaded!"
} else {
# close bracet extra documentated
bind pub - !google pub:google:cmd
bind pub - !image pub:image:cmd
#bind pub - !file pub:file:cmd
# with this we avoid using the syncronous gethostbyname with CONNECT in egghttp
dnslookup www.google.de getgoogledns:cb
proc getgoogledns:cb {ip host status} {
set ::googleip $ip
}
proc pub:google:cmd {nick uhost hand chan arg} {
pub:google $nick $uhost $hand $chan google $arg
return 1
}
proc pub:image:cmd {nick uhost hand chan arg} {
pub:google $nick $uhost $hand $chan image $arg
return 1
}
#proc pub:file:cmd {nick uhost hand chan arg} {
# pub:google $nick $uhost $hand $chan file $arg
# return 1
#}
proc pub:google {nick uhost handle chan type arg} {
if {[llength $arg]==0} {
putserv "PRIVMSG $channel :Baka, baka, baka !!!"
} else {
set query "http://$::googleip/search?btnI=&q="
for { set index 0 } { $index<[llength $arg] } { incr index } {
set query "$query[lindex $arg $index]"
if {$index<[llength $arg]-1} then {
set query "$query+"
}
}
switch $type {
image {append query &imgsafe=off}
file {return 0}
default {}
}
# Note: Useragent must start with Mozilla/ for google
if { [catch {egghttp:geturl $query "pub:google:cb $nick $chan" -useragent "Mozilla/4.0 (TCL 8.4.7; egghttp 1.1.0; CYGWIN_NT-5.1)"} err] } {
puthelp "NOTICE $nick :$err"
}
}
}
proc pub:google:cb {nick chan token} {
set headers [egghttp:headers $token]
if {[regexp "Location:(.*)\n" $headers {} newurl]} {
puthelp "PRIVMSG $chan :[string trim $newurl]"
} elseif { [string match -nocase "*HTTP/1.? 200 OK*" $headers] } {
puthelp "NOTICE $nick :No match found"
} else {
puthelp "NOTICE $nick :Unknown error while phrasing google output"
}
}
#proc pub:file { nick uhost handle channel arg } {
# global agent
# if {[llength $arg]==0} {
# putserv "PRIVMSG $channel :hey ! tappes un nom de fichier boulet !"
# } else {
# set query "http://www.filemirrors.com/find.src?file="
# set query "$query[lindex $arg 0]"
# set token [http::config -useragent $agent]
# if {[catch {set token [http::geturl $query]} sockerr]} {
# puthelp "NOTICE $nick :$sockerr"
# puthelp "NOTICE $nick :Try again later, look out the window till then!"
# return 0
# }
# set html [http::data $token]
# upvar #0 $token state
# set max 0
# set result "[lindex $html 1]"
# set result [string range $result [expr [string first = $result]+2] [expr [string first > $result]-2]]
# putserv "PRIVMSG $channel :$result"
# return 1
# }
#}
putlog "Google 1.0.0 - LOADED!"
# close bracet from egghttp check
} |
Note: !image doesnt work correctly atm., and I haven't rewritten the !file search, since its not google, but filemirror.com . _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
Longbow Voice
Joined: 13 Jan 2005 Posts: 29
|
Posted: Thu Feb 24, 2005 5:44 pm Post subject: |
|
|
This doesn't help the original poster but... | Quote: | Note: !image doesnt work correctly atm., and I haven't rewritten the !file search, since its not google, but filemirror.com . |
| Code: | bind pub - !image pub:image
proc pub:image { nick uhost handle channel arg } {
global agent
if {[llength $arg]==0} {
putserv "NOTICE $nick :You need to enter a image."
} else {
set query "http://images.google.de/images?btnI=&q="
for { set index 0 } { $index<[llength $arg] } { incr index } {
set query "$query[lindex $arg $index]"
if {$index<[llength $arg]-1} then {
set query "$query+"
}
}
append query &imgsafe=off
set token [http::config -useragent $agent]
set token [http::geturl $query]
puts stderr ""
upvar #0 $token state
set max 0
foreach {name value} $state(meta) {
if {[regexp -nocase ^location$ $name]} {
set starturl "http://"
set newurl [string trim $value]
set newurl [string range $newurl [expr [string first = $newurl]+1] [expr [string first & $newurl]-1]]
append starturl $newurl
putserv "PRIVMSG $channel :$arg: $starturl"
}
}
}
} | ^^ Thats what i've got for google image. |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Thu Feb 24, 2005 11:41 pm Post subject: |
|
|
no need to copy google-0.2.1.tcl, I already said it is a rewrite from this script as its original (even you maybe nolonger would recognize it, because I nearly rewrote everything).
| Code: | # De Kus' google port from http to egghttp
#
# 1.1.1 25.02.2005 fixed remote code execution from $nick
# 1.1.0 25.02.2005 !image rewrote done
# 1.0.1 24.02.2005 changed query string creation
# 1.0.0 24.02.2005 rewrote done
#
# following orignal header:
#
# google.tcl v0.2.1
#
# !google keywords - displays the first related website found from google in the channel
# !image keywords - displays the first related image found on google in the channel
# !file keywords - displays the first mirror download link found on filemirrors in the channel
#
# by aNa|0Gue - analogue@glop.org - http://www.glop.org/
#
# 04/17/2002 v0.2.1 useragent fix by FAN
if { ![info exists egghttp(version)] } {
putlog "Could not verify egghttp.tcl beeing loaded!"
} else {
# close bracet extra documentated
bind pub - !google pub:google:cmd
bind pub - !image pub:image:cmd
#bind pub - !file pub:file:cmd
# with this we avoid using the syncronous gethostbyname with CONNECT in egghttp
dnslookup www.google.de getgoogledns:cb
proc getgoogledns:cb {ip host status} {
set ::googleip $ip
}
proc pub:google:cmd {nick uhost hand chan arg} {
pub:google $nick $uhost $hand $chan google $arg
return 1
}
proc pub:image:cmd {nick uhost hand chan arg} {
pub:google $nick $uhost $hand $chan image $arg
return 1
}
#proc pub:file:cmd {nick uhost hand chan arg} {
# pub:google $nick $uhost $hand $chan file $arg
# return 1
#}
proc pub:google {nick uhost handle chan type arg} {
if {[llength $arg]==0} {
putserv "PRIVMSG $channel :Baka, baka, baka !!!"
} else {
set query "?btnI=&q=[string map {" " + \" %22 , %2C : %3A ; %3B \t %09 ! %21 # %23 \$ %24 % %25 & %26 ' %27 ( %28 ) %29 = %3D § %C2%A7} $arg]"
switch $type {
image {set query "http://$::googleip/images${query}&imgsafe=off"}
file {return 0}
default {set query "http://$::googleip/search$query"}
}
# Note: Useragent must start with Mozilla/ for google
if { [catch {egghttp:geturl $query [split "pub:google:cb $nick $chan $type"] -useragent "Mozilla/4.0 (TCL 8.4.7; egghttp 1.1.0; CYGWIN_NT-5.1)"} err] } {
puthelp "NOTICE $nick :$err"
}
}
}
proc pub:google:cb {nick chan type token} {
set headers [egghttp:headers $token]
switch $type {
image {
if { [set found [regexp "imgurl\075(.*)\046imgrefurl" $headers {} newurl]] } {
set newurl "http://$newurl"
}
}
file {return 0}
default {set found [regexp "Location:(.*)\n" $headers {} newurl]}
}
if {$found} {
puthelp "PRIVMSG $chan :[string trim $newurl]"
} elseif { [string match -nocase "*HTTP/1.? 200 OK*" $headers] } {
puthelp "NOTICE $nick :No match found"
} else {
puthelp "NOTICE $nick :Unknown error while phrasing google output"
}
}
#proc pub:file { nick uhost handle channel arg } {
# global agent
# if {[llength $arg]==0} {
# putserv "PRIVMSG $channel :hey ! tappes un nom de fichier boulet !"
# } else {
# set query "http://www.filemirrors.com/find.src?file="
# set query "$query[lindex $arg 0]"
# set token [http::config -useragent $agent]
# if {[catch {set token [http::geturl $query]} sockerr]} {
# puthelp "NOTICE $nick :$sockerr"
# puthelp "NOTICE $nick :Try again later, look out the window till then!"
# return 0
# }
# set html [http::data $token]
# upvar #0 $token state
# set max 0
# set result "[lindex $html 1]"
# set result [string range $result [expr [string first = $result]+2] [expr [string first > $result]-2]]
# putserv "PRIVMSG $channel :$result"
# return 1
# }
#}
putlog "Google 1.0.0 - LOADED!"
# close bracet from egghttp check
} |
Note: I replaced the stupid foreach with a string map expression, which replaces most important special charters. you should be able to search like in google itself, something like
| Code: | | eggdrop "news & more" -porn |
will be absolutly fine.
Things you might want to change:
Line 30: dnslookup ... getgoogledns:cb
Line 61: -useragent "..."
yes, google.de has a sligthly diffrent search result than google.com! maybe you use your local google.whatever to optimize your result . _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
Ofloo Owner
Joined: 13 May 2003 Posts: 953 Location: Belguim
|
Posted: Sat Feb 26, 2005 4:32 am Post subject: |
|
|
| ^DooM^ wrote: | The only google script i found that actually worked uses
| Code: | | package require http |
I can send it you if you wish tho. |
it is not the working but the crashing using http lib crashes the bot .. ive seen it manytimes .. main reason why i never use that package anywhere .. _________________ XplaiN but think of me as stupid |
|
| Back to top |
|
 |
Thunderdome Op

Joined: 15 Mar 2005 Posts: 187
|
Posted: Thu Mar 17, 2005 6:59 pm Post subject: |
|
|
how can that googgle script (I also use it) work with filemirror?
That is the only part of the script that does not work....
and how can one show 3 or X google results instead of one? |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Thu Mar 17, 2005 8:07 pm Post subject: |
|
|
| Code: | # De Kus' google port from http to egghttp
#
# 1.2.1 18.03.2005 regexp for !file rewritten, fixed remote code execution
# 1.2.0 18.03.2005 !file rewrote done
# 1.1.1 25.02.2005 fixed remote code execution from $nick
# 1.1.0 25.02.2005 !image rewrote done
# 1.0.1 24.02.2005 changed query string creation
# 1.0.0 24.02.2005 rewrote done
#
# following orignal header:
#
# google.tcl v0.2.1
#
# !google keywords - displays the first related website found from google in the channel
# !image keywords - displays the first related image found on google in the channel
# !file keywords - displays the first mirror download link found on filemirrors in the channel
#
# by aNa|0Gue - analogue@glop.org - http://www.glop.org/
#
# 04/17/2002 v0.2.1 useragent fix by FAN
if { ![info exists egghttp(version)] } {
putlog "Could not verify egghttp.tcl beeing loaded! Failed to load google."
} else {
# close bracet extra documentated
bind pub - !google pub:google:cmd
bind pub - !image pub:image:cmd
bind pub - !file pub:file:cmd
# with this we avoid using the syncronous gethostbyname with CONNECT in egghttp
dnslookup www.google.de getgoogledns:cb
dnslookup www.filemirrors.com getfmdns:cb
proc getgoogledns:cb {ip host status} { set ::googleip $ip }
proc getfmdns:cb {ip host status} { set ::fmip $ip }
set googleflood 0
proc pub:google:cmd {nick uhost hand chan arg} {
pub:google $nick $uhost $hand $chan google $arg
return 1
}
proc pub:image:cmd {nick uhost hand chan arg} {
pub:google $nick $uhost $hand $chan image $arg
return 1
}
proc pub:file:cmd {nick uhost hand chan arg} {
pub:google $nick $uhost $hand $chan file $arg
return 1
}
proc pub:google {nick uhost handle chan type arg} {
global googleflood
if { $googleflood > 4 } {
puthelp "NOTICE $nick :Genug gesucht erstmal."
return 0
} elseif { $::googleip == "0.0.0.0" || $::fmip == "0.0.0.0" } {
puthelp "NOTICE $nick :Sorry, I don't have the cached IPs. If this persists DNS lookup is broken. Requesting now..."
dnslookup www.google.de getgoogledns:cb
dnslookup www.filemirrors.com getfmdns:cb
return 0
}
incr googleflood
timer 5 [list incr googleflood -1]
if {[llength [split $arg]]==0} {
putserv "PRIVMSG $channel :Baka, baka, baka !!!"
} else {
set query [string map {" " + \" %22 , %2C : %3A ; %3B \t %09 ! %21 # %23 \$ %24 % %25 & %26 ' %27 ( %28 ) %29 = %3D § %C2%A7} $arg]
switch $type {
image {set query "http://$::googleip/images?btnI=&q=${query}&imgsafe=off"}
file {set query "http://$::fmip/find.src?file=$query"}
default {set query "http://$::googleip/search?btnI=&q=$query"}
}
# Note: Useragent must start with Mozilla/ for google
if { [catch {egghttp:geturl $query [split "pub:google:cb $nick $chan $type"] -useragent "Mozilla/4.0 (TCL 8.4.7; egghttp $::egghttp(version); de-DE; OpenBSD 3.4)"} err] } {
puthelp "NOTICE $nick :$err"
}
}
}
proc pub:google:cb {nick chan type token} {
set headers [egghttp:headers $token]
switch $type {
image {
if { [set found [regexp "imgurl\075(.*)\046imgrefurl" $headers {} newurl]] } {
set newurl "http://$newurl"
}
}
file {set found [regexp {(?n)<a href=\"(.*)\">} [egghttp:data $token] {} newurl]}
default {set found [regexp "Location:(.*)\n" $headers {} newurl]}
}
if {$found} {
puthelp "PRIVMSG $chan :[string trim [string map {%25 %} $newurl]]"
} elseif { [string match -nocase "*HTTP/1.? 200 OK*" $headers] || $type == "file" && [string match -nocase "*not found" [egghttp:data $token]] } {
puthelp "NOTICE $nick :No match found"
} else {
puthelp "NOTICE $nick :Unspecified error while phrasing webserver output."
}
}
putlog "Google 1.2.2 - LOADED!"
# close bracet from egghttp check
} |
This should do for filemirror, but still everything in "single output". I am not absolutly sure about the url part string length, currently filename must shorter than 40 chars (included %xx codes) and hostname shorter than 50 chars. extension must be 1-5 chars. why? Because regexp tends to catch the widest string avaible, which could more be than 1 line in case of multimatchs (at least it did once for me ).
for multiline you would have to rewrite a lot. Feel free to change it, I won't that soon .
For xgoogle goes the same, I don't need xgoogle, but I am sure, it could be easily integreated ^-^.
PS: I am running that script with a "sligthly" changed/enhanced egghttp.tcl, but it should not matter, but there is no guarantee for that . _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Last edited by De Kus on Sun Apr 24, 2005 6:05 pm; edited 2 times in total |
|
| Back to top |
|
 |
Thunderdome Op

Joined: 15 Mar 2005 Posts: 187
|
Posted: Thu Mar 17, 2005 9:38 pm Post subject: |
|
|
ftp://ftp.nero.com/Nero-6.6.0.8a.exe">Nero-6.6.0.8a.exe</a><br>
for example... is the result for the search of Nero-6.6.0.8a.exe!
so something must be wrong... but it works...
Anyway, why can't one search just "nero"? if one does that no results are shown... do I need to use the full name to search it? |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Thu Mar 17, 2005 10:19 pm Post subject: |
|
|
stupid regex, the gimmi a headache. but finally I know how to corectly prevent multiline matching, so the best regexp is:
regexp {(?n)<a href=\"(.*)\">} [egghttp:data $token] {} newurl
filemirror is intended to be used for searching an alternitive server (so Ill probably add a feature to get something else than mirror #1) and not a file search. for a file search your are better with !google .
PS: I replaced the code above, better copy completly, because I added a [split ] to where llengeth is used. _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
cambodia Halfop

Joined: 22 Aug 2004 Posts: 73 Location: cambodia
|
Posted: Fri Mar 18, 2005 2:58 am Post subject: |
|
|
yeah better copy all and change it or you can make as tcl release for everybody to use , i interesting in this tcl too  |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Fri Mar 18, 2005 9:47 am Post subject: |
|
|
| cambodia wrote: | yeah better copy all and change it or you can make as tcl release for everybody to use , i interesting in this tcl too  |
| Quote: | Posted: Today at 3:19 am Reply with quoteEdit/Delete this postBack to top
stupid regex, ... |
| Quote: | | Last edited by De Kus on Fri Mar 18, 2005 3:20 am; edited 1 time in total |
maybe I have already updated the previous post?! _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
NTHosts Op
Joined: 10 Oct 2005 Posts: 100 Location: UK
|
Posted: Tue May 02, 2006 7:28 am Post subject: ummm |
|
|
Hi, just tried to use this script but keep getting this error on rehash
[06:25] Could not verify egghttp.tcl beeing loaded! Failed to load google.
any ideas ?  _________________ www.NT-Hosts.Net - More than just a host |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Tue May 02, 2006 8:31 am Post subject: |
|
|
load egghttp before google?!  _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
NTHosts Op
Joined: 10 Oct 2005 Posts: 100 Location: UK
|
Posted: Tue May 02, 2006 9:04 am Post subject: ... |
|
|
DOH !!
/me slaps his forehead  _________________ www.NT-Hosts.Net - More than just a host |
|
| Back to top |
|
 |
|