Gets information on IP address
Commands: !ipinfo
bind pub - !ipinfo ipinfo
proc ipinfo {nick host hand chan arg} {
package require http
if {$arg == ""} { putserv "PRIVMSG $chan :You must provide an ip address to check!"
} else {
set url "http://www.melissadata.com/lookups/iplocation.asp?ipaddress=$arg"
set page [http::data [http::geturl $url]]
if {[regexp {is not valid} $page]} {
putserv "PRIVMSG $chan :Syntax error: Ip must be in the form of 1.2.3.4"
} else {
while {[regexp -line {columresult'>(.*?)<\/td>.*?<b>(.*?)<\/b>} $page a section info]} {
regsub {columresult'>(.*?)<\/td>.*?<b>(.*?)<\/b>} $page "" page
putserv "PRIVMSG $chan :$section: [recode $info]"
}
}
}
}
proc recode {text} {
return [string map {" \" · "" & & ""} [subst [regsub -nocase -all {&#([0-9]{1,5});} $text {\u\1}]]]
}
putlog "IPInfo"