mIRC Home    About    Download    Register    News    Help

Topic Options
#265113 - 10/03/19 02:56 AM Get first lines of /names command
miguelpucela Offline
Nutrimatic drinks dispenser

Registered: 10/03/19
Posts: 7
Loc: Spain
Hello,
I'm trying to make a script that echos the first 3 lines of the output of the comand /names #channel.

I've being guessing of geting the output of names command into a variable, but I don't know how to do it.

I supose there's a better way to do it.

Any help or tip is welcome.

Thank you in advance.
Miguel

Top
#265114 - 10/03/19 09:40 AM Re: Get first lines of /names command [Re: miguelpucela]
Raccoon Offline
Hoopy frood

Registered: 18/02/03
Posts: 2594
Why only the first 3 lines?

Is it a channel that you're already in? If so, you can just use $nick(#,%i) to iterate though them.

RAW 353:*: { } will fire for each line of names listings

RAW 366:*: { } will fire for End of /Names List.

Use /debug -p @debug
_________________________
Well. At least I won lunch.
Good philosophy, see good in bad, I like!

Top
#265115 - 10/03/19 04:43 PM Re: Get first lines of /names command [Re: Raccoon]
miguelpucela Offline
Nutrimatic drinks dispenser

Registered: 10/03/19
Posts: 7
Loc: Spain
I want to make a command to execute it in the status window. Let's say I want to print the first N lines of the names output of the M input arguments of the command:

/mycommand #chan1 #chan2 ... #chanM 4

The output should be the first 4 lines of the /names output of the M channels.

Another option could be to print the last M users connected to each channel.

Top
#265118 - 11/03/19 12:43 AM Re: Get first lines of /names command [Re: miguelpucela]
Raccoon Offline
Hoopy frood

Registered: 18/02/03
Posts: 2594
Are these channels that you are already joined to, or are these channels that you are sitting outside of?
_________________________
Well. At least I won lunch.
Good philosophy, see good in bad, I like!

Top
#265129 - 11/03/19 05:45 PM Re: Get first lines of /names command [Re: Raccoon]
miguelpucela Offline
Nutrimatic drinks dispenser

Registered: 10/03/19
Posts: 7
Loc: Spain
In principle these are channels I'm sitting outside of.

Top
#265249 - 22/03/19 07:04 PM Re: Get first lines of /names command [Re: miguelpucela]
Erasimus Offline
Babel fish

Registered: 26/04/18
Posts: 72
I too don't understand why you only want the 1st 3 lines.

I also dont understand why you find this difficult.
Code:
 
; set line counter to 1 and then only echo the lines 1-3
; to the status window. Use haltdef to prevent mIRC
; from sending any line to status window.
; needs to be set at some point -- say @ raw 001
On raw 001 :*: {
   Set %LineCounter 1
}

On raw 353:*: {
   if (%LineCounter <= 3) { //echo -s $1- }
   inc %LineCounter
   haltdef
}

; reset counter to 1 ready for next channel
On raw 366:*: { %LineCounter = 1 }


Of course this will affect any usage of the /names command, so you could set a variable in your 'mycommand' which you test for in the above on raw events, then reset that variable at the end of your command, to allow for normal usage.


Edited by Erasimus (22/03/19 07:19 PM)

Top
#265252 - 22/03/19 10:52 PM Re: Get first lines of /names command [Re: Erasimus]
Raccoon Offline
Hoopy frood

Registered: 18/02/03
Posts: 2594
Not every network outputs RAW 001. Use On Connect instead to initialize your variables.
_________________________
Well. At least I won lunch.
Good philosophy, see good in bad, I like!

Top
#265253 - 23/03/19 01:19 AM Re: Get first lines of /names command [Re: Erasimus]
miguelpucela Offline
Nutrimatic drinks dispenser

Registered: 10/03/19
Posts: 7
Loc: Spain
The final objective is to get the last users connected to several channels in only one command invokation.

I'm new to mirc scripting. That's why I find this difficult eek

Thank you for your help.

Top
#265373 - 08/04/19 03:35 AM Re: Get first lines of /names command [Re: miguelpucela]
Erasimus Offline
Babel fish

Registered: 26/04/18
Posts: 72
Ooops, I forgot something from the last part of the code I gave.
Code:
; reset counter to 1 ready for next channel
On raw 366:*: { 
   %LineCounter = 1
   haltdef
}


As stated in the comments at the start of the previous code I detailed, haltdef tells mIRC to NOT display it's default output from the raw 366 message, namely the 'End of /NAMES list.'

Sorry about that .. I was coding on the fly at the time of my previous posting

Top
#265374 - 08/04/19 04:12 AM Re: Get first lines of /names command [Re: Erasimus]
miguelpucela Offline
Nutrimatic drinks dispenser

Registered: 10/03/19
Posts: 7
Loc: Spain
I'm a bit confused ... I was trying to make a function in the Aliases window, but I cannot see any piece of code with that syntax (On raw ...) ... So I don't know where I'm suppose to include that code confused

Top
#265375 - 08/04/19 04:41 AM Re: Get first lines of /names command [Re: miguelpucela]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 1144
aliases window can only hold aliases, without the alias keyword. The alt+R remotes tab can have aliases, as well as events, so the ON events go there.

Good reading on various topics here

Top
#265376 - 09/04/19 01:44 AM Re: Get first lines of /names command [Re: miguelpucela]
miguelpucela Offline
Nutrimatic drinks dispenser

Registered: 10/03/19
Posts: 7
Loc: Spain
So after reading a bit and reading your code, I think I cannot do what I mean.

With your code, what I get is first 3 lines of names command everytime I invoke /names command.

What I wanted is to create a command (or alias) with which I get first 3 lines of names of each channel is input as argument of that command, but all the users are output if the normal /names command is used.

I don't know if inside a alias (or a command) I can set a flag variable that I can read inside a raw event to decide wether to output all the lines of names or only the first 3 ...

Top
#265377 - 09/04/19 07:38 PM Re: Get first lines of /names command [Re: miguelpucela]
Erasimus Offline
Babel fish

Registered: 26/04/18
Posts: 72
You missed a bit from my 1st post in this thread:
Quote:
Of course this will affect any usage of the /names command, so you could set a variable in your 'mycommand' which you test for in the above on raw events, then reset that variable at the end of your command, to allow for normal usage.


If I remeber correctly your alias is called 'MyCommand'. In there set a variable to 1 and at the end of that alias set it to 0 (zero). Into that section On Raw 353

You put a test of that variable and only execute the code I wrote if it is true (i.e. is equal to 1).

Change things to this as an example
Code:
On raw 001 :*: {
   Set %LineCounter 1
}

On raw 353:*: {
   if (%MyTrigger) {
      if (%LineCounter <= 3) { //echo -s $1- }
      inc %LineCounter
      haltdef
   }
}

; reset counter to 1 ready for next channel
On raw 366:*: { 
   if (%MyTrigger) {
      %LineCounter = 1
      haltdef
   }
}


Now your My command will set %MyTrigger to 1, and any name commands that the alias sends will only get the 1st 3 lines displayed, and when all channels have been processed, you alias sets %MyTrigger to 0. If you then type /names #<whatever> the 'if %MyTrigger' will be false and those lines about %linecounter and haltdef are not executed.


Edited by Erasimus (09/04/19 07:39 PM)

Top
#265378 - 10/04/19 02:24 AM Re: Get first lines of /names command [Re: Erasimus]
miguelpucela Offline
Nutrimatic drinks dispenser

Registered: 10/03/19
Posts: 7
Loc: Spain
Thank you!!

Now it's much clearer smile

Top