mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2018
Posts: 3
R
Recce Offline OP
Self-satisified door
OP Offline
Self-satisified door
R
Joined: Feb 2018
Posts: 3
Hello. I'm trying to take certain lines of text from multiple chat rooms that contain multiple keywords that I am interested in, and have them printed out into a single window or chatroom. My understanding is that I can use regex to get multiple results of different keywords, so I've been trying to learn... but it never works in my filter commands.

Beyond that, I originally thought the /filter command could be iterated a bunch of times on each room I care about, and then I could filter the filter window using /filter again to sort everything. The problem is I don't know how the sorting switch (or any switches on filter for that matter) works.

I create a window and I post a few things into my chatroom, #testchannel:

/window -ew @filter

[12 14:47:34 <@flt1354> takeoff 1445 UTC
[12 14:47:53 <@flt1354> at assigned altitude by 1500 UTC
[12 14:49:20 <@flt1817> landing in 00+15
[12 14:50:14 <@flt1817> land time 1505 UTC
[12 14:52:52 <@controller> flt1354 descend and maintain FL320
[12 14:53:15 <@controller> flt 1354 unresponsive!

Now I try to filter this with the command filter:

/filter #testchannel @filter
gives me all of the traffic that was in #testchannel in @filter

/filter @filter @filter *land*
filters filter to just lines containing *land* and gives me:
[12 14:49:20 <@flt1817> landing in 00+15
[12 14:50:14 <@flt1817> land time 1505

However, I can't get regex or any other switches to work at all when I try them. For example, when I try:
/filter c @filter @filter *controller*
**Attempt to clear window and replace data with lines containing controller**
I get an error: * /filter: invalid window

/filter g @filter @filter controller|land(ing)?
**Attempt to show lines containing controller or land or landing
same thing... error: * /filter: invalid window

/filter wwc #testchannel @filter *land*
error: * /filter: invalid window

I'm pretty sure I'm not putting the regex into the form mIRC wants, as I just started learning it today, but I think the switches are messed up too because I can't get a single one of them to work. This happens with any of the filter switches. Could this be a server problem? Filter is supposed to be able to accept a wide range of switches, being of the form:

/filter [-asdfhNkwxnpriocteubglLz] [n-n2] [c s] <infile | dialog id> <outfile | dialog id | alias> [alias] <matchtext>

The only thing that will display anything is the simplest form of the /filter command with a single variable *text*, so I get one variable I can pull from. I can't even get the filter command to work properly as a standalone at this time. The only thing I can think to do now is make a tedious alias that successively filters each individual thing I'm looking for, from each individual room. But then everything will be out of order instead of being in chronological order by timestamp.

1) If there was a way to automate /filter to check a bunch of criteria at once instead of running filter a bunch of times that would be awesome. Even better if it could hit multiple chatrooms. The best way I know of to do that would be to have the script manually pull one iteration at a time, for each of the rooms I list in an alias.

2)When done pulling lines, filter all the lines in @filter so they list in chronological order based on timestamp

3) If there was some way to get the filter window to update with new information every so often (either by setting something in scripts or setting it via the window input line) that would be even better, but for now I'm ok with just running a script every time if it actually works...

Sorry for this huge post. I imagine the solution is pretty simple. I am not a programmer so hopefully someone can help.

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Your errors are because you only used the hyphen indicating switch on the first attempt, but not in any of the others, making it think you're using filename wwc as your input, invalid attempt to use a #channel as output, and searching for text string @filter followed by *land*. Multiple switches are combined as 1 parameter, but it must begin with the hyphen.

Some switches require the presence of an additional parameter. For example, the n-n2 parameter should only be used when using the -r switch, and the c and s parameters should only be used alongside the -t switch.

There's several websites that try to teach regex, once you're ready to create a search, you can use regex101.com to try "what if" scenarios to see whether you're matching everything you should and aren't matching things you shouldn't. While learning what you can and can't do in a regex search, you should try getting a search/pattern working there before using it in mIRC. There are some cases where commas and other special characters are not handled as you might not expect, so it's probably a good idea to put the search string in %pattern then use %pattern as your regex string.

var %pattern (land|controller)
//filter -wwg #channel @window %pattern

Returns lines containing either string, but also finds them when they're part of another word, such as bland or grand.

var %pattern \b(land|controller)\b

This forces the match to be a whole word. However there are no switches being used, and regex defaults to being case-sensitive, so if you want to match either Land or land, it needs to be case-insensitive

var %pattern /\b(land|controller)\b/i

1. You can't use multiple windows as your input. You'll need to hit them in series.

2. If you want to use the timestamp for sorting, you might need to alter the format to include the seconds, and possibly the date, to prevent 23:00 sorted after 07:00. You're wanting to sort by the 1st token of the line, and your tokens are split by the space character 32, so "c s" are "1 32".

3. To update at intervals, you can use /timer. I assume you would want to avoid repeating things that displayed the prior time. You can save the prior output to another window first, then can examine the current output for matches against the old-match window. Otherwise you would "/clear #channel" after getting matches so they can't be found again.

Joined: Feb 2018
Posts: 3
R
Recce Offline OP
Self-satisified door
OP Offline
Self-satisified door
R
Joined: Feb 2018
Posts: 3
Thank you very much, this is just what I needed. I have it working now without the timer, so I'll try to implement that next.

Two things that helped me to understand the regex was trying the patterns in sublime text to make sure they did what I intended, vs checking in mIRC.

To get my times to sort properly, I used this:

//sorttime {
if ($1 < $2) return -1
elseif ($1 > 2) return 1
else return 0
}

I imagine all sorts with /filter are of this form, but the mIRC documentation doesn't exactly make it easy to understand. I tried it initially and the times were backwards, so I just reversed the variables and it worked, hah.

Last edited by Recce; 13/02/18 05:51 AM.
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
It looks like you're using sorttime as the -a alias. It works, but you're doing it the hard way. You're doing something like:

/filter -wwga #channelname @window sorttime RegexMatchText

with some echoes you can see that $1 and $2 are the entire line pairs. Since you're doing a simple sort, it would be faster to let the -t switch do the sort for you. The -a alias is for more complex sorts, such as sorting by token 4 with a tie-breaker being token 2.

/filter -wwgt 1 32 #channelname @window RegexMatchText

Since your sorting token does not begin with only-numerics, the -u switch for a numeric sort would have no effect.


Link Copied to Clipboard