pony

ip info

May 30th, 2020
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. ; Grabs JSON from: http://ipinfo.io/{$ip}/geo
  2. ; Syntax: !ipinfo <IP>
  3.  
  4. #ipx on
  5. on *:text:*:#:{ if (?ipinfo iswm $1 && $2 && $left($1,1) isin .@!) { getip $2 # } }
  6. on *:input:#:{ if (?ipinfo iswm $1 && $server && /* !iswm $1 && $2 && $left($1,1) isin .@!) { getip $2 # } }
  7. #ipx end
  8.  
  9. alias -l getip {
  10. sockclose xip
  11. sockopen -46 xip ipinfo.io 80
  12. sockmark xip $1
  13. %xchan = $2
  14. %xline = ""
  15. }
  16. on *:sockopen:xip:{
  17. if ($sockerr) { msg %xchan [IPinfo] $c Open Error! | unset %xchan %xline | return }
  18. sockwrite -n $sockname GET $+(http://ipinfo.io/,$sock($sockname).mark,/geo) HTTP/1.1
  19. sockwrite -n $sockname Host: ipinfo.io
  20. sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0
  21. sockwrite -n $sockname Accept-Language: en-US
  22. sockwrite -n $sockname Content-Type: application/json; charset=utf-8
  23. sockwrite -n $sockname $str($crlf,2)
  24. }
  25. on *:sockread:xip:{
  26. if ($sockerr) { msg %xchan [IPinfo] $c Read Error! | unset %xchan %xline | return }
  27. var %x, %2
  28. sockread -f %x
  29. tokenize 32 %x
  30. if ("*": * iswm $1-) {
  31. var %2 = $remove($2-,",$chr(44))
  32. if ($1 == "ip":) { %xline = [IPinfo] $c IP: %2 }
  33. if ($1 == "city":) { %xline = %xline $c City: %2 }
  34. if ($1 == "region":) { %xline = %xline $c Region: %2 }
  35. if ($1 == "country":) { %xline = %xline $c Country: %2 }
  36. if ($1 == "loc":) { %xline = %xline $c Location: $replace(%2,-,$+($chr(44),-)) }
  37. if ($1 == "timezone":) { %xline = %xline $c Timezone: %2 | endxit | sockclose $sockname }
  38. }
  39. if ($chr(125) isin $1) { endxit | sockclose $sockname }
  40. }
  41. alias -l endxit {
  42. if (%xline) { msg %xchan %xline }
  43. else { msg %xchan [IPinfo] $c Nothing found! }
  44. unset %xline %xchan
  45. }
  46. alias -l c { return $chr(9679) }
Advertisement
Add Comment
Please, Sign In to add comment