Code: Select all
package require http
bind pub - !pv pub:pv
set agent "Mozilla"
proc pub:pv { nick uhost handle channel arg } {
global agent
if {[llength $arg]==0} {
putserv "PRIVMSG $channel :Keyword please."
} else {
set query "http://www.google.com/search?btnI=&q=purevolume&"
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"
}
}
}
}
However, with the purevolume& addition, I get
Code: Select all
[13:00] Tcl error [pub:pv]: can't read "query": no such variable
I'm really new to TCL, so it's probably a dumb mistake.