Advertisement
OrFeAsGr

Ipinfo replacement

Feb 5th, 2018
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 2.04 KB | None | 0 0
  1. #ip on
  2.  
  3. on *:text:*:#:{ if (?ipinfo iswm $1 && $2 && $left($1,1) isin .@!) { ipit $2 # } }
  4. on *:input:#:{ if (?ipinfo iswm $1 && $server && /* !iswm $1 && $2 && $left($1,1) isin .@!) { ipit $2 # } }
  5.  
  6. alias c { return $chr(8226) }
  7.  
  8. alias -l ipit {
  9.   if (127.* iswm $1 || 192.168.* iswm $1 || 10.* iswm $1 || *localhost* iswm $1) { msg $2 No local addresses! | return }
  10.   sockclose ipit
  11.   sockopen ipit ip-api.com 80
  12.   sockmark ipit $1
  13.   %newchan = $2
  14.   %line = ""
  15. }
  16. on *:sockopen:ipit:{
  17.   if ($sockerr) { msg %newchan [IPinfo] $c Open Error! | unset %newchan %line | return }
  18.   sockwrite -n $sockname GET $+(/json/,$sock($sockname).mark) HTTP/1.1
  19.   sockwrite -n $sockname Host: ip-api.com
  20.   sockwrite -n $sockname Connection: keep-alive
  21.   sockwrite -n $sockname Accept: */*
  22.   sockwrite -n $sockname Accept-Language: en-us
  23.   sockwrite -n $sockname User-Agent: Mozilla/4.0
  24.   sockwrite -n $sockname Content-Type: text/html
  25.   sockwrite -n $sockname $str($crlf,2)  
  26. }
  27. on *:sockread:ipit:{
  28.   if ($sockerr) { msg %newchan [IPinfo] $c Read Error! | unset %newchan %line | return }
  29.   var %x
  30.   sockread -f %x
  31.   tokenize 32 %x
  32.  
  33.   if ($+(*,$chr(123),*) iswm $1-) {
  34.     var %a = 1, %b, %x, %x2
  35.     while ($gettok($1-,%a,44)) {
  36.       %b = $v1
  37.       %x = $remove($gettok(%b,1,58),")
  38.       %x2 = $remove($gettok(%b,2,58),")
  39.       if ($+($chr(123),as) != %x && %x != zip) { set -u5 $eval($+(%,%x),1) %x2 }
  40.       inc %a
  41.     }
  42.   }
  43.   if (%country) {
  44.     %line = [IpInfo] $c IP: $sock($sockname).mark
  45.     if (%country) { %line = %line $c Country: %country $c }
  46.     if (%city) { %line = %line City: %city $c }
  47.     if (%regionName) { %line = %line State: %regionName $c }
  48.     if (%isp) { %line = %line ISP: %isp $c }
  49.     if (%lon) { %line = %line Longitude: %lon $c }
  50.     if (%lat) { %line = %line Latitude: %lat $c }
  51.     sockclose $sockname
  52.     endit
  53.   }
  54. }
  55. alias -l endit {
  56.   if (!%line) { msg %newchan [IpInfo] $c Nothing Found! }
  57.   else { msg %newchan $gettok(%line,1--2,32) }
  58.   unset %line %newchan %city %regionName %country %lat %lon %isp
  59. }
  60. #ip end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement