Advertisement
Guest User

Untitled

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