A simple IP to Country

By biase on Oct 29, 2017

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)
}
;----------------------------------------------------------------------
; 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. $+ $ticks | .comopen %a msxml2.xmlhttp
    noop $com(%a,send,$com(%a,open,1,bstr,GET,bstr,$+(http://ip-api.com/line/,$1,?fields=country),bool,true))
    .comclose %a $com(%a,ResponseText,2) $regex(ip2c,$com(%a).result,(.+))
  }
  return $regml(ip2c,1)
}

Here is the new update.. enjoy~

Comments

Sign in to comment.
ovelayer   -  Oct 18, 2018

seems to have stopped working

biase  -  Nov 26, 2019

yea... and sorry i not really an active mirc user..

Sign in to comment

x1L22   -  Oct 30, 2017

Great job thans

biase  -  Nov 01, 2017

welcome.. glad to you like it

ovelayer  -  Nov 04, 2017

works fast and good..thanks

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.