mIRC Home    About    Download    Register    News    Help

Print Thread
#264167 06/11/18 03:51 AM
Joined: Mar 2015
Posts: 26
A
Anti Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Mar 2015
Posts: 26

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

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
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.

Joined: Mar 2015
Posts: 26
A
Anti Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Mar 2015
Posts: 26

>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 ?

Joined: Mar 2015
Posts: 26
A
Anti Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Mar 2015
Posts: 26
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- }

Joined: Jul 2006
Posts: 4,180
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,180
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.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Mar 2015
Posts: 26
A
Anti Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Mar 2015
Posts: 26

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

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
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.

Joined: Mar 2015
Posts: 26
A
Anti Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Mar 2015
Posts: 26
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


Last edited by Anti; 15/11/18 12:34 AM.
Joined: Feb 2011
Posts: 461
K
Pan-dimensional mouse
Offline
Pan-dimensional mouse
K
Joined: Feb 2011
Posts: 461
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 }
}

Joined: Mar 2015
Posts: 26
A
Anti Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Mar 2015
Posts: 26

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 ?

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
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)


Link Copied to Clipboard