Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package require http
- package require json
- bind pub - .who who
- proc who {nick uhost hand chan text} {
- set lookup [lindex [split $text] 0]
- catch {set http [::http::geturl http://ipinfo.io/$lookup/json -timeout 6000]} error
- set data [::http::data $http]
- set json [::json::json2dict $data]
- ::http::cleanup $http
- set keys [dict keys $json]
- set expecting {ip hostname city region country loc postal phone org}
- foreach ele $expecting {
- if {[lsearch $keys $ele] != -1} {
- set $ele [dict get $json $ele]
- } else {
- set $ele "n/a"
- }
- }
- putserv "PRIVMSG $chan :\002(\002Geo\002)\002: IP: $ip - Hostname: $hostname - City: $city - Region: $region - Country: $country - Location: $loc - Zipcode: $postal - Organization: $org"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement