Example of the site: https://ipinfo.io/8.8.8.8/json
Code: Select all
proc geo {n u h c t} {
catch {set http [::http::geturl http://ipinfo.io/[lindex $t 0]/json -timeout 6000]} error
if {[string match "*error*" $error]} { putserv "PRIVMSG $c :connect error!" ; return 0 }
if {[string match "*timeout*" $error]} { putserv "PRVMSG $c :timeout!"; return 0 }
set html [::http::data $http]
if {[string match "*Not Found*" $html]} { putserv "PRIVMSG $c :GeoIP: No data found." ; return }
regexp -line -- {<"ip":>(.*)</ip>} $html -> ipz
regexp -line -- {<"hostname":>(.*)</hostname>} $html -> hostname
regexp -line -- {<"city":>(.*)</city>} $html -> city
regexp -line -- {<"region">(.*)</region>} $html -> region
regexp -line -- {<"country":>(.*)</country>} $html -> country
regexp -line -- {<"loc":>(.*)</loc>} $html -> loc
regexp -line -- {<"org":>(.*)</org>} $html -> org
putserv "PRIVMSG $c :IP: $ipz - Hostname: $hostname - City: $city - Region: $region - Country: $country - Location: $loc - Organization: $org"
http::cleanup $http
}
Does anyone have any suggestion or help why I am getting this error? Thanks[11:09:20] Tcl error [geo]: can't read "ipz": no such variable