Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ip on
- on *:text:*:#:{ if (?ipinfo iswm $1 && $2 && $left($1,1) isin .@!) { ipit $2 # } }
- on *:input:#:{ if (?ipinfo iswm $1 && $server && /* !iswm $1 && $2 && $left($1,1) isin .@!) { ipit $2 # } }
- alias c { return $chr(8226) }
- alias -l ipit {
- if (127.* iswm $1 || 192.168.* iswm $1 || 10.* iswm $1 || *localhost* iswm $1) { msg $2 No local addresses! | return }
- sockclose ipit
- sockopen ipit ip-api.com 80
- sockmark ipit $1
- %newchan = $2
- %line = ""
- }
- on *:sockopen:ipit:{
- if ($sockerr) { msg %newchan [IPinfo] $c Open Error! | unset %newchan %line | return }
- sockwrite -n $sockname GET $+(/json/,$sock($sockname).mark) HTTP/1.1
- sockwrite -n $sockname Host: ip-api.com
- sockwrite -n $sockname Connection: keep-alive
- sockwrite -n $sockname Accept: */*
- sockwrite -n $sockname Accept-Language: en-us
- sockwrite -n $sockname User-Agent: Mozilla/4.0
- sockwrite -n $sockname Content-Type: text/html
- sockwrite -n $sockname $str($crlf,2)
- }
- on *:sockread:ipit:{
- if ($sockerr) { msg %newchan [IPinfo] $c Read Error! | unset %newchan %line | return }
- var %x
- sockread -f %x
- tokenize 32 %x
- if ($+(*,$chr(123),*) iswm $1-) {
- var %a = 1, %b, %x, %x2
- while ($gettok($1-,%a,44)) {
- %b = $v1
- %x = $remove($gettok(%b,1,58),")
- %x2 = $remove($gettok(%b,2,58),")
- if ($+($chr(123),as) != %x && %x != zip) { set -u5 $eval($+(%,%x),1) %x2 }
- inc %a
- }
- }
- if (%country) {
- %line = [IpInfo] $c IP: $sock($sockname).mark
- if (%country) { %line = %line $c Country: %country $c }
- if (%city) { %line = %line City: %city $c }
- if (%regionName) { %line = %line State: %regionName $c }
- if (%isp) { %line = %line ISP: %isp $c }
- if (%lon) { %line = %line Longitude: %lon $c }
- if (%lat) { %line = %line Latitude: %lat $c }
- sockclose $sockname
- endit
- }
- }
- alias -l endit {
- if (!%line) { msg %newchan [IpInfo] $c Nothing Found! }
- else { msg %newchan $gettok(%line,1--2,32) }
- unset %line %newchan %city %regionName %country %lat %lon %isp
- }
- #ip end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement