can you post the complete working script here bro , if you don't mind?sysusr wrote:Forgot to reply back. Script works flawless now. Thank you
can you post the complete working script here bro , if you don't mind?sysusr wrote:Forgot to reply back. Script works flawless now. Thank you
Code: Select all
package require http
package require json
bind pub m|- !ginfo Pub:Geo:INFO
proc Pub:Geo:INFO {nick uhost hand chan text} {
if {[scan $text {%s} lookup] != 1} {
puthelp "NOTICE $nick :Error, syntax is: !Ginfo <ip>"
return
}
if {![regexp {([0-9]+\.)([0-9]+\.)([0-9]+\.)([0-9]+)} $lookup]} {
puthelp "NOTICE $nick :Error, the IP you mentioned is not valid."
return
}
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]
foreach ele {ip hostname city region country loc postal phone org} {
set $ele [expr {[lsearch $keys $ele] > -1 ? [dict get $json $ele] : "n/a"}]
}
puthelp "NOTICE $nick :IP: $ip - Hostname: $hostname - City: $city - Region: $region - Country: $country - Location: $loc - Organization: $org"
}
Code: Select all
package require http
package require json
package require ip
bind raw - NOTICE server:notices
proc server:notices {from keyword text} {
if {![string match -nocase "*client connecting*" $text]} return
set lookup [lindex [split $text] 6]
if {[::ip::version $lookup] < 4} return
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]
foreach ele {ip hostname city region country loc postal phone org} {
set $ele [expr {[lsearch $keys $ele] > -1 ? [dict get $json $ele] : "n/a"}]
}
puthelp "PRIVMSG #Opers :$nick - $ip - $country"
}
{
"status": "ok",
"2806a:7699:e094:f36d:6b6c:7a23": {
"proxy": "no",
"type": "Business"
}
}