Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Grabs JSON from: http://ipinfo.io/{$ip}/geo
- ; Syntax: !ipinfo <IP>
- #ipx on
- on *:text:*:#:{ if (?ipinfo iswm $1 && $2 && $left($1,1) isin .@!) { getip $2 # } }
- on *:input:#:{ if (?ipinfo iswm $1 && $server && /* !iswm $1 && $2 && $left($1,1) isin .@!) { getip $2 # } }
- #ipx end
- alias -l getip {
- sockclose xip
- sockopen -46 xip ipinfo.io 80
- sockmark xip $1
- %xchan = $2
- %xline = ""
- }
- on *:sockopen:xip:{
- if ($sockerr) { msg %xchan [IPinfo] $c Open Error! | unset %xchan %xline | return }
- sockwrite -n $sockname GET $+(http://ipinfo.io/,$sock($sockname).mark,/geo) HTTP/1.1
- sockwrite -n $sockname Host: ipinfo.io
- sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0
- sockwrite -n $sockname Accept-Language: en-US
- sockwrite -n $sockname Content-Type: application/json; charset=utf-8
- sockwrite -n $sockname $str($crlf,2)
- }
- on *:sockread:xip:{
- if ($sockerr) { msg %xchan [IPinfo] $c Read Error! | unset %xchan %xline | return }
- var %x, %2
- sockread -f %x
- tokenize 32 %x
- if ("*": * iswm $1-) {
- var %2 = $remove($2-,",$chr(44))
- if ($1 == "ip":) { %xline = [IPinfo] $c IP: %2 }
- if ($1 == "city":) { %xline = %xline $c City: %2 }
- if ($1 == "region":) { %xline = %xline $c Region: %2 }
- if ($1 == "country":) { %xline = %xline $c Country: %2 }
- if ($1 == "loc":) { %xline = %xline $c Location: $replace(%2,-,$+($chr(44),-)) }
- if ($1 == "timezone":) { %xline = %xline $c Timezone: %2 | endxit | sockclose $sockname }
- }
- if ($chr(125) isin $1) { endxit | sockclose $sockname }
- }
- alias -l endxit {
- if (%xline) { msg %xchan %xline }
- else { msg %xchan [IPinfo] $c Nothing found! }
- unset %xline %xchan
- }
- alias -l c { return $chr(9679) }
Advertisement
Add Comment
Please, Sign In to add comment