tglogo.png
0 LIKES

Snippet


A simple IP to Country by biase

In Category General IRC Posted by Snippets On 12/06/23

A simple IP to Country
A simple non-socket ip to country that will return a country name based on ip.
;----------------------------------------------------------------------
; Author      : bruas aka biase @ Webchat, unclean @ DalNet, Lite @ KampungChat
; Name        : A simple IP to Country
; URL         : -
; Description : A simple non-socket ip to country that will return a country name based on ip.
;             : It will trigger when a user use like this $ip2country(<ip>).
; Example     : //echo $ip2country(216.58.196.46)
; Created     : 1509274412
;----------------------------------------------------------------------
alias ip2country {
  if ($longip($1)) {
    var %a ajax. $+ $regsubex($str(.,10),/./g,$mid($md5($time),$r(1,32),1))
    .comopen %a msxml2.xmlhttp
    noop $com(%a,send,$com(%a,open,1,bstr,GET,bstr,$+(http://geoip.nekudo.com/api/,$1),bool,true))
    .comclose %a $com(%a,ResponseText,2) $regex($com(%a).result,/"name":"(.+?)"\54/)
  }
  return $iif($regml(1),$v1)
}


Comments 0


Please note that on our website we use cookies necessary for the functioning of our website, cookies that optimize the performance. To learn more about our cookies, how we use them and their benefits, please read our Cookie Policy.
I Understand