Code: Select all
package require http
Code: Select all
# 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 .
Code: Select all
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"
}
}
}
}
Code: Select all
# 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
}
Code: Select all
eggdrop "news & more" -porn
^DooM^ wrote:The only google script i found that actually worked usesI can send it you if you wish tho.Code: Select all
package require http
Code: Select all
# 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
}
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
Posted: Today at 3:19 am Reply with quoteEdit/Delete this postBack to top
stupid regex, ...
maybe I have already updated the previous post?!Last edited by De Kus on Fri Mar 18, 2005 3:20 am; edited 1 time in total