Hello, I just reinstalled my eggdrop bot and I am having and issue with getting several of my old scripts working. I have installed this on a new server.
My server is gentoo, with the latest version of tcl available in an ebuild. I can't tell you exactly what version I am using.
I get the following error in regards to this line (proc pub:google { nick uhost handle channel arg } {) ...
wrong # args: should be { join nick uhost handle channel arg }
I have tried changing it but still doesn't work, I just get another error. Can anyone help? What is causing this? Something new in TCL?
# 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
package require http
bind pub - !google pub:google
bind pub - !image pub:image
bind pub - !file pub:file
set agent "Mozilla"
proc pub:google { nick uhost handle channel arg } {
global agent
if {[llength $arg]==0} {
putserv "PRIVMSG $channel :hey ! tappes des mots boulet !"
} else {
set query "http://www.google.de/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+"
}
}
#putserv "PRIVMSG $channel :$query"
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 newurl [string trim $value]
putserv "PRIVMSG $channel :$newurl"
}
}
}
}
proc pub:image { nick uhost handle channel arg } {
global agent
if {[llength $arg]==0} {
putserv "PRIVMSG $channel :hey ! tappes des mots boulet !"
} 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
# putserv "PRIVMSG $channel :$query"
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 :$starturl"
}
}
}
}
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]"
# putserv "PRIVMSG $channel :$query"
set token [http::config -useragent $agent]
set token [http::geturl $query]
set html [http::data $token]
puts stderr ""
upvar #0 $token state
set max 0
# foreach {name value} $state(meta) {
# putserv "PRIVMSG $channel :$value"
# }
# putserv "PRIVMSG $channel :$html"
set result "[lindex $html 1]"
set result [string range $result [expr [string first = $result]+2] [expr [string first > $result]-2]]
putserv "PRIVMSG $channel :$result"
}
}
putlog "Google v0.2.1 - LOADED!"
have completly restarted your bot with that script?
can you give us the more detailed error from '.set errorInfo'?
have you accidently loaded another google script?
if you have my egghttp port of this script in memory you would encounter the problem because of this line:
pub:google $nick $uhost $hand $chan google $arg
you can easily check this by doing a '.binds pub' in the partyline, if you have a bind to pub to the function pub:google:cmd this would proabably be your problem and you would only have to unbind that (if you dont want to .restart your bot) ^^.
this is basicly the same idea of script, just a bit optimized and rewritten from the package http which often causes problems to the save and non-blocking egghttp (package is the wrong expression, its just a tcl script providing some functions). http://forum.egghelp.org/viewtopic.php?t=9207
then you have probably it disabled in the .conf file ^^
but very strange, if you really checked all I mentioned, I cannot help here.
neither my script neither the script posted above can produce that error as they are, there must be an other script interferring with them (unless you do a .restart, once loaded scripts won't unload just because you removed their source and did a .rehash).
then you have probably it disabled in the .conf file ^^
but very strange, if you really checked all I mentioned, I cannot help here.
neither my script neither the script posted above can produce that error as they are, there must be an other script interferring with them (unless you do a .restart, once loaded scripts won't unload just because you removed their source and did a .rehash).
Well, restart your bot and load the scripts seperately i.e. 1 by 1 and check out if the problem still there.
I'm an idiot, At least this one [bug] took about 5 minutes to find...
# by murf
# Commands
# .google keyword(s) <# of results>
# e.g. .google sick 5
# default number of returns
set google_def_num 4
# max number of returns
set google_max 10
set glpubbind .google
set gl_output "NOTICE $nick"
bind pub -|- $glpubbind pub_google
proc pub_google {nick uhost handle chan search} {
global gl_ouput
set gl_output "NOTICE $nick"
if {[llength $search] == 0} {
puthelp "$gl_output : Whatcha searchin for fool!?"
return 0
}
set url [google_url $search $nick $chan]
google_getpage $url
return 0
}
# Google_url #
# Takes input and parses to set the url, returns the url
proc google_url {search nick chan} {
global google_def_num google_max gl_output
set google_num [lindex $search end]
if {[regexp { [0-9]+} $search match $google_num]} {
if {$google_num > $google_max} { set google_num $google_max }
set search [lrange $search 0 [expr {[llength $search] - 2}]]
} else {
set google_num $google_def_num
}
if {$google_num >= 5} {
set gl_output "NOTICE $nick"
} else {
set gl_output "PRIVMSG $chan"
}
regsub -all { } $search {+} search
set url "/search?hl=en&num=$google_num&lr=&ie=ISO-8859-1&q=$search"
return $url
}
# google_getpage #
# gets the webpage and parses for the returns
proc google_getpage {url} {
global gl_output
## Open socket
if {[catch {set glsock [socket -async www.google.com 80]} sockerr]} {
puthelp "NOTICE $nick :$sockerr"
puthelp "NOTICE $nick :Try again later, look out the window till then!"
close $glsock
return 0
}
puts $glsock "GET $url"
flush $glsock
set i 0
set j 1
set glout [gets $glsock]
while {[regexp {Dissatisfied with your results?} $glout] == 0} {
set glout [gets $glsock]
incr i
if {$i >= 150} {
break
}
if {[regexp {#008000>(.*?) - } $glout match gl_result($j)]} {
puthelp "$gl_output :$j. http://$gl_result($j)"
incr j
}
}
close $glsock
return 0
}
I'm an idiot, At least this one [bug] took about 5 minutes to find...