Project

General

Profile

ipinfo help

Added by C. Syem over 7 years ago

OK, so i have this script from mIRC who acces ipinfo.io json and extract information about IP:

alias whois {
  if ($longip($1)) {
    var %e echo $color(whois) $iif($active == Status Window,-s,$active), %h 1, %r
    var %a ajax. $+ $upper($regsubex($str(.,10),/./g,$mid($md5($time),$r(1,32),1)))
    .comopen %a msxml2.xmlhttp
    %e $chr(160)
    %e $str($chr(160),5) 14[  $1  14]
    noop $com(%a,send,$com(%a,open,1,bstr,GET,bstr,$+(http://ipinfo.io/,$1,/json),bool,true)) $com(%a,ResponseText,2)
    %r = $remove($replace($remove($com(%a).result,$({,0),$(},0),"),$+($chr(44),$lf),=),$lf)
    if ($count(%r,=)) {
      while ($gettok(%r,%h,61)) {
        %e $str($chr(160),5) $(12[,0) $regsubex($v1,(.+):,$+($upper(\1),$str($chr(160),$calc(11-$len(\1))),:))
        inc %h
      }
    }
    %e $str($chr(160),5) 14[ Info end 1 4]
    %e $chr(160)
    .comclose %a
  }
  else whois $1
}

How can i make this to work? I search for something similar here but i don't find anything.


Replies (16)

RE: ipinfo help - Added by Per Amundsen over 7 years ago

This script seems to work fine, does it not work for you?

Edit. by seem to work, I mean seems to works the same in mirc/adiirc.

RE: ipinfo help - Added by C. Syem over 7 years ago

I don't get any information, no errors, nothing.

RE: ipinfo help - Added by Per Amundsen over 7 years ago

The msxml2.xmlhttp com object doesn't seem to work in either mirc or adiirc, at least not on windows 10, does it work for you in mirc?

RE: ipinfo help - Added by C. Syem over 7 years ago

Now i use windows 7 but also was working in windows 10 if i use it twice.

RE: ipinfo help - Added by Per Amundsen over 7 years ago

I threw this together, if you know a little scripting, you should be able to expand on it.

alias whois {
  if ($longip($1)) {
    sockopen ipinfo ipinfo.io 80
    sockmark ipinfo $1
  }
  else whois $1
}

on *:sockopen:ipinfo:{
  sockwrite -tn $sockname GET http://www.ipinfo.io/ $+ $sock($sockname).mark $+ /json HTTP/1.1
  sockwrite -tn $sockname Host: www.ipinfo.io
  sockwrite -tn $sockname Connection: close
  sockwrite -tn $sockname $crlf
}

on *:sockread:ipinfo:{
  var %s
  sockread %s
  if ($regex(%s, /\"(.*?)\": \"(.*?)\"/g)) {
    echo -ag $regml(1) = $regml(2)
  }
}

RE: ipinfo help - Added by C. Syem over 7 years ago

Thank you, i will expand it to get similar output.

RE: ipinfo help - Added by Per Amundsen over 7 years ago

Someone was kind and fix the original script in case somebody else wants to use that method.

alias whois {
  if ($longip($1)) {
    var %echo, %xhr, %i

    %echo = echo $color(whois) $iif($active == status window, -s, $active);

    %xhr = $ticks $+ 000
    while ($com(whoisip. $+ %xhr)) {
      inc %xhr
    }
    %xhr = whoisip. $+ %xhr

    .comopen %xhr MSXML2.ServerXMLHttp.6.0
    if (!$com(%xhr) || $comerr) {
      %echo [WHOIS IP] Lookup failed: unable to create request instance
    }
    elseif (!$com(%xhr, open, 1, bstr, GET, bstr, $+(http://ipinfo.io/, $1, /json), bool, false) || $comerr) {
      %echo [WHOIS IP] Lookup failed: Unable to specify request parameters
    }
    elseif (!$com(%xhr, send, 1) || $comerr) {
      %echo [WHOIS IP] Lookup failed: request failed
    }
    elseif (!$com(%xhr, readystate, 2) || $comerr || $com(%xhr).result !== 4) {
      %echo [WHOIS IP] Lookup failed: connection failed
    }
    elseif (!$com(%xhr, responseText, 2) || $comerr) {
      %echo [WHOIS IP] Lookup failed: Unable to retrieve response body
    }
    else {
      noop $regex($com(%xhr).result, /\s*"([^"]+)":\s*"([^\"]+)"/g)
      if (!$regml(0)) {
        %echo [WHOIS IP] No data for $1
      }
      else {
        var %i = 1
        while (%i < $regml(0)) {
          %echo [WHOIS IP] $regml(%i) $+ : $regml($calc(%i +1))
          inc %i 2
        }
      }
    }
    if ($com(%xhr)) .comclose %xhr
  }
  else whois $1
}

RE: ipinfo help - Added by C. Syem over 7 years ago

Thanks. Is working flawless.

I also have this suggestions:

Song option for "on query". I mean just only when a query is open. Right now is for private message and is kinda annoying.
Maybe some improvements for Emoticons to have a options to select what size to have for them. Right now you are limited by font size, so will be nice to have a option to make them better visible with a small font size.
Save last connection/server. Sometimes i chose a server from my list or i just type one and i quit. When i open it and press the first icon to connect me, will be nice to connect me to the last server i was previously.
Color nick in messages. I would like to see in Color sections an option to select your nick color for messages (only nick).
Short version for join/part. Right now is "nick (ident@host) joins #channel". That part with "join #channel" is kinda useless. Of course you know what channel is, don't need to mention it for every part or join. Will be nice to make an options "exclude name channel" or a "short join/part" similar to mIRC where you see only "Joins: nick (ident@host)". I know you can make it in few seconds from script, but not everyone know how to do it.
Another problem, i was having nick Example1 and when i type another server and connect there my nick changed, also my Fullname. Why doesn't remain the same nick, same settings? The server i write it wasn't in the server list, so i don't know where he takes that nick. I guess from quick connect. But quick connect is disabled. I delete everything from quick connect, i connect to a server with nick, ident, fullname X, i type another server and again he take another nick, ident, fullname from somewhere else. So, whats the deal here?
I know you say that you will make an option to color windows in switchbar, so also include that in suggestions.

I should make a separated topic for suggestions?

RE: ipinfo help - Added by Per Amundsen over 7 years ago

Song option for "on query". I mean just only when a query is open. Right now is for private message and is kinda annoying.

Not sure what you mean by this ?

Maybe some improvements for Emoticons to have a options to select what size to have for them. Right now you are limited by font size, so will be nice to have a option to make them better visible with a small font size.

Due to how the message buffer works, each line of text must have the same height, so emoticons are resized to fit inside the line height, you can however add more spacing between the lines with Options Dialog -> Messages -> Pixel spacing, not sure if it has the effect you want, give it a try.

Save last connection/server. Sometimes i chose a server from my list or i just type one and i quit. When i open it and press the first icon to connect me, will be nice to connect me to the last server i was previously.

In AdiIRC new server windows uses the server set in Options -> Quick Connect, however there is a server history in Menubar -> Server.

Color nick in messages. I would like to see in Color sections an option to select your nick color for messages (only nick).

Check Options -> Nick Colors.

Short version for join/part. Right now is "nick (ident@host) joins #channel". That part with "join #channel" is kinda useless. Of course you know what channel is, don't need to mention it for every part or join. Will be nice to make an options "exclude name channel" or a "short join/part" similar to mIRC where you see only "Joins: nick (ident@host)". I know you can make it in few seconds from script, but not everyone know how to do it.

I have this on TODO.

Another problem, i was having nick Example1 and when i type another server and connect there my nick changed, also my Fullname. Why doesn't remain the same nick, same settings? The server i write it wasn't in the server list, so i don't know where he takes that nick. I guess from quick connect. But quick connect is disabled.

New server windows uses quick connect settings, that includes from /server as well.

I know you say that you will make an option to color windows in switchbar, so also include that in suggestions.

In last public beta I added option to use a background image for Switchbar buttons, you can type /betaup to get it.

RE: ipinfo help - Added by C. Syem over 7 years ago

For sound on query, i mean only if someone will send you a message and a query will open. Will play just only one single time (when a new query is open), not every time when you get a message in private windows. So if someone send you a message and a windows query is open, a sound will play. Don't need to play a sound every time you get a message in private (like the present option for Private message) because is really annoying if someone will send you message every few seconds.

That Pixel spacing fix the emoticons size, should be added also in Emoticons like a option, emoticons size lets say.

I see that "server history" but i don't like it because will autoconnect you. Will be nice if the client will do this:
- if you change your nickname in chat /nick Example, also the client change the nick in Quick Connect.
- when you connect to a server and after that you quit/close the client, also the client change the server from Quick Connect.
- will be good if you will have an icon next to Settings for Quick Connect.
In this way i think the client will have some true "history" when you open it. And you just open it, if you want to change the nick click on Quick Connect, if you don't just click on fist icon and you get the last server. Don't need to go again in Server list, chose again that znc/bnc/server connection, maybe change the nick. Too many operation for something who should be simple after you open it again.

For nick color, my fault. I miss that option :))) sorry

RE: ipinfo help - Added by Per Amundsen over 7 years ago

I'll think about adding a separate option to only play a sound when a private window is opened or other solutions.

The pixel spacing is for messages, not related to emoticons, so it should be in Messages, but I will update the wiki pages to reflect that it can be used to expand emoticons as well.

I know you want new server windows to work like mIRC and use the last settings, but the way it works in AdiIRC has been like this for many years, so it can't be changed now, however I'll think about adding a option to change how quick connect works.

Normal flow is to add servers to the Serverlist, you can then connect them automatically by using the "Connect this server on startup" or by using /server <label of the server> or mark the server as a favourite and access it from the Toolbar, the Serverlist wiki explains how that works or just by clicking Connect in the Serverlist.

I think more Toolbar icons (if that's what you meant) would be great, but I don't have someone who can make icons for me atm, but it's on my TODO.

RE: ipinfo help - Added by C. Syem over 7 years ago

Yes, more icons/options for Toolbar will be great. I use some icons in my mIRC script but i don't remember where did i get it (google) or if they are free for commercial. Will be awesome to have a few standard design themes (only for toolbar, switchbar) and each theme with separated icons and design. You can find some nice free icons on the net or i could help you with some donations if you find someone who wanna design some unique icons special for AdiIRC.

And btw i also want to ask you how can i change individual icons in Toolbar? In mIRC i have something like this:

on 1:START:{
  toolbar -r
  toolbar -p Connect icons\example.ico
}

I am sure also is working here but what are the "shortcuts" for buttons?

RE: ipinfo help - Added by Per Amundsen over 7 years ago

Check the /toolbar command, then names is different in AdiIRC.

RE: ipinfo help - Added by Per Amundsen over 7 years ago

Sorry missed the last one, what do you mean shortcuts?

RE: ipinfo help - Added by C. Syem over 7 years ago

No no, you show me what i was looking for. Shortcuts was the name for buttons (tsb1, tsb2, tsb3, tsb4...)
This is my buttons right now:

RE: ipinfo help - Added by Per Amundsen over 7 years ago

Option to only play sound when a private window is opening was added last beta, an option to use update Quick Connect settings with the last connected server is added for next beta.

    (1-16/16)