mIRC Home    About    Download    Register    News    Help

Topic Options
#264167 - 06/11/18 03:51 AM how parsing whois output ?
Anti Offline
Ameglian cow

Registered: 06/03/15
Posts: 20

Hello,
I need to parse the whois $$1 output , but I don't know
to do it.

How may I assign whois $$1 output to a variable to be
parsed after ?

For example :

set %b whois $$1 $$1

echo -a %b ; return whois nick nick

Anyone may help me ?

Thank you

Top
#264168 - 06/11/18 04:52 AM Re: how parsing whois output ? [Re: Anti]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 970
among many other things, the output from whois appears in a raw numeric event. different networks have different numerics included in their output, some lines you see only on yourself, some appear only if someone is marked as /away, some are seen only by server admins, etc.

This should show a lot of red lines mixed in with the whois output, so you can see which lines are caused by which numeric. You'll also see that the whois reply you do see has often been rearranged from what's received, and some things are dropped or re-formatted. As with many messages sent to you through raw's, there's often a numeric for the beginning of the whois, and another numeric to signal the end of that person's whois.

FYI: you often get a different reply for the 'idle' line using "whois nick nick" vs "whois nick", depending on whether you both share the same server.

Try putting this line in a script to see the raw events where you would need to harvest your data. You would need to have checks like

if ($numeric == 1234) { do stuff }

Code:
raw *:*:{ echo 4 -s debug raw: nick $nick raw $numeric : (1) $1 (2) $2 (3) $3 (4) $4 (5) $5 (6-) $6- }


And yes, Talon, I saw your regex for dynamic numbers, but wanted to keep it simple.

Top
#264184 - 08/11/18 12:12 AM Re: how parsing whois output ? [Re: maroon]
Anti Offline
Ameglian cow

Registered: 06/03/15
Posts: 20

>Please I need to put the whois output in a variable,
not to know another stuff.

How may I put whois output in a variable ?

Top
#264185 - 08/11/18 12:35 AM Re: how parsing whois output ? [Re: maroon]
Anti Offline
Ameglian cow

Registered: 06/03/15
Posts: 20
Originally Posted By: maroon

This should show a lot of red lines mixed in with the whois output, so you can see which lines are caused by which numeric. You'll also see that the whois reply you do see has often been rearranged from what's received, and some things are dropped or re-formatted. As with many messages sent to you through raw's, there's often a numeric for the beginning of the whois, and another numeric to signal the end of that person's whois.

FYI: you often get a different reply for the 'idle' line using "whois nick nick" vs "whois nick", depending on whether you both share the same server.

Try putting this line in a script to see the raw events where you would need to harvest your data. You would need to have checks like

if ($numeric == 1234) { do stuff }



I know irc protocol , it's 30 years and more old , please don't explaine me
obvious things.

mIRC is full of strange things , for example what is the $numeric identifier ?
Why 1234 and not another number ?
irc is a simple protocol usable in raw mode with program as telnet or netcat.

I'm using mIRC for historical reasons, but if I don't found a solution
for a simple thing as put a value in a variable or array I change
client , there are a lot of another client with support for more
standardizated and powerfull scripting language as perl , python or ruby.


Code:
raw *:*:{ echo 4 -s debug raw: nick $nick raw $numeric : (1) $1 (2) $2 (3) $3 (4) $4 (5) $5 (6-) $6- }

Top
#264186 - 08/11/18 12:44 AM Re: how parsing whois output ? [Re: Anti]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3438
Loc: France
If you know the irc protocol you should know that a whois output is made of multiple data, which are sent over via what's called raw, so for each piece of infos, you have to assign the value to a variable, there's no such things as getting the output from a function because the data has to be sent from the server, mIRC doesn't store that, there's no easy way to do that, you would have the same issue with python.
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#264187 - 08/11/18 02:37 AM Re: how parsing whois output ? [Re: Wims]
Anti Offline
Ameglian cow

Registered: 06/03/15
Posts: 20

there is no way to parse the server raw output ?

the raw event have many obscure code as 322 :

raw 322:*mirc*:/echo 5 $1-

322 is the code for the /list output.

Possible don't exist a code per whois output ?

With python and other script languages , it's possible
parsing the server output and matching what do you want

Top
#264188 - 08/11/18 04:27 AM Re: how parsing whois output ? [Re: Anti]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 970
You're confusing. You say you know IRC protocol, but then in your next sentence you show that you don't know what a numeric is. In a later post you want to parse the "server output", then you say you know that 322 is the code for the "/list output". 322 is the NUMERIC for ONE of the kinds of SERVER output generated after you use the /list command. There's also a 321 NUMERIC that indicates the beginning of the server's reply to /list. There's also a 323 NUMERIC to indicate the end of the server's reply. Sorry if I'm boring you since I can't tell what you know and what you don't know, what you think is "another stuff".

Just as there's not 1 single NUMERIC in reply to /list, there's not a single numeric response from the server after you use the /whois command. The "another stuff" was to display all the numeric responses by the server to all kinds of things. I didn't give a list of them because the variety varies depending on which network, who you did a /whois against, what network privileges you have at the time, etc. The last network I joined had /whois output completely different than I'd encountered at prior networks.

By giving you a raw event which shows you which numerics were in response to that particular /whois, it shows what I was trying to explain, which you allegedly know already, that the server output shown by this debug script is different than the way it appears in your status window. The debug lines will be interleaved with the way mirc reformats the /whois output to display in your status window.

You'd face all these same issues if you were using python, anaconda, ruby, or topaz.

Top
#264271 - 15/11/18 12:23 AM Re: how parsing whois output ? [Re: maroon]
Anti Offline
Ameglian cow

Registered: 06/03/15
Posts: 20
Thank you very much for your answer , and sorry if I'm answering you late.
I losed some particular of the irc protocol, sorry for my errors.
In fact I tried to connect in raw mode ( with netcat ), and with mIRC in raw mode
with this command from the prompt:
//window -e @raw | debug @raw

Basically the "raw event" are numbers in the txt string
sended to the client before the colon : , in fact the client write only what is after colon :
This is a piece of raw output :

https://pastebin.com/T23Gpgzm

Similar is with mIRC.

I noticed the raw event dont work inside a if-then statement control. For example this code don't work :

-----
if ( server1 isin $server ) { msg $nick hello }

if ( server2 isin $server {

whois $nick

raw 311:*chatt-free*:{ msg $nick Compliment , you are using $3 server }


}
else msg $nick you are using the normal server $server

----
The above code give me a error.

It seems that raw event work only in the root of the logic program flux,( not nested )
but I need to make a choose before run the raw parsing
( only in the second case run whois $nick ), and after run the raw parsing of the string out.

How may I solve the problem with mIRC scripting ?

Thank you



Edited by Anti (15/11/18 12:34 AM)

Top
#264276 - 15/11/18 06:02 PM Re: how parsing whois output ? [Re: Anti]
KindOne Offline
Fjord artisan

Registered: 23/02/11
Posts: 307
Are you trying to do something like this?

Code:
; /whois KindOne

raw 312:*:{ 
 
  ; :irc.atw-inter.net 312 Prill KindOne irc.atw-inter.net :EU Open Server, Provided by ATW Internet Kft.
  ; $1 Prill
  ; $2 KindOne
  ; $3 irc.atw-inter.net
  
  ; For everyone on atw-inter servers.
  if (*.atw-inter.* iswm $3) { msg $2 Compliment, you are using $3 server } 

  ; For everyone on freenode servers.
  else if (*.freenode.* iswm $3) { msg $2 You are connected to $3 server } 

  ; All the other networks.
  else { msg $2 You are on normal server $server }
}
_________________________
irc.swiftirc.net #msl (mIRC Scripting Language)

Top
#264303 - 18/11/18 03:41 AM Re: how parsing whois output ? [Re: KindOne]
Anti Offline
Ameglian cow

Registered: 06/03/15
Posts: 20

Ok, this code works, but isn't new for me.

The problem is that I have 2 servers , and ONLY for one
I must do whois to see what server are using the user.

Basically I must the raw command choose only for one server.
I noticed that raw don't go in a nestled routine as if-then-else.

How may I do it ?

Top
#264305 - 18/11/18 07:06 AM Re: how parsing whois output ? [Re: Anti]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 970
I think you're asking how to cause the 312 numeric take action only at 1 network and not at any others? If so, you can begin the 312 handler like:

Code:
if ($network != dalnet) return


(or whatever is the name value used by your network)

Top