mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2011
Posts: 53
S
Babel fish
OP Offline
Babel fish
S
Joined: May 2011
Posts: 53
Hi all,

I'm using this currently:

Quote:
if (giggles isin $2) || (grins isin $2) || (laughs isin $2) || (laughter isin $2) || (roars isin $2) && (720p.HDTV.X264-2HD isin $6) || (720p.HDTV.X264-COMPULSiON isin $6) || (720p.HDTV.x264-DIMENSION isin $6) || (720p.HDTV.x264-EVOLVE isin $6) || (720p.HDTV.x264-ORENJI isin $6) {

if (giggles isin $4) || (grins isin $4) || (laughs isin $4) || (laughter isin $4) || (roars isin $4) && (720p.HDTV.X264-2HD isin $6) || (720p.HDTV.X264-COMPULSiON isin $6) || (720p.HDTV.x264-DIMENSION isin $6) || (720p.HDTV.x264-EVOLVE isin $6) || (720p.HDTV.x264-ORENJI isin $6) {



But will this also work?:

Quote:
if (*giggles* iswm $2-4) || (*grins* iswm $2-4) || (*laughs* iswm $2-4) || (*laughter* iswm $2-4) || (*roars* iswm $2-4) && (*720p.HDTV.X264-2HD* iswm $4-6) || (*720p.HDTV.X264-COMPULSiON* iswm $4-6) || (*720p.HDTV.x264-DIMENSION* iswm $4-6) || (*720p.HDTV.x264-EVOLVE* iswm $4-6) || (*720p.HDTV.x264-ORENJI* iswm $4-6) {



Also, is there a way to shorten/improve this version?

smile


Finally, how would I modify this

Quote:
var %rl = $5


to match var %rl anywhere from 4-6 in the announce: I'm guessing simply:

Quote:
var %rl = $4-6


Last edited by sandygws; 25/09/12 01:11 PM.
Joined: Jan 2004
Posts: 1,361
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,361
giggles isin is logically the same as *giggles* iswm - I would assume that isin could be more efficient. If, however, the text you're matching occurs at the beginning or end you can use giggles* iswm or *720p.HDTV.X264-COMPULSiON iswm as these are more restrictive.

As for deciding to use $2 or $4, context would help deciding but you can probably parse it out correctly into only one variable using a regex, or just checking the $network or $chan.

All that said, you might want to consider using hash tables to separate your filters from your code. I'll give some explanation for the following code:

The main alias here is "check", you can call it like /check %release or $check(%release), it returns 1 when there's a match and $null when there isn't. When the check alias is called, it makes sure that the hash tables are loaded. Then it checks the group first by looking up a wildcard match with $hfind. If it can't find a match, or if the value of that filter is 0 or $null, it returns $null. This way, the data of your filter acts as an enable/disable switch so you can disable a filter without deleting it completely. It does this same checking for what I called a tag, your "giggles" etc. If it matches a tag as well the alias finishes and returns 1.

The other aliases are used to facilitate working with the hash tables. I've made these aliases local with the -l switch except for tables.load, so when you're manually editing your filter.ini file you can call /tables.load to reload your changes. After you're all set up, it would be best if you put the -l back.

Code:
on *:start:{ tables.load }

alias check {
  var %release = $$1-
  
  if (!$hget(group)) { table.load group }
  if (!$hget(tag)) { table.load tag }
  
  var %group = $hfind(group,%release,1,W)
  if (!%group) || (!$hget(group,%group)) { return }
  
  var %tag = $hfind(tag,%release,1,W)
  if (!%tag) || (!$hget(tag,%tag)) { return }
  
  echo -ag Group: 3 $+ %group $+  Tag: 5 $+ %tag $+ 
  return 1
}

alias -l table.load {
  hfree -w $$1
  hload -i $1 filter.ini $1
}

alias -l table.save {
  hsave -i $$1 filter.ini $1
}

alias tables.load {
  table.load group
  table.load tag
}

alias -l tables.save {
  table.save group
  table.save tag
}

I've got some debug text in there right now, so calling "/check giggles.720p.HDTV.x264-DIMENSION" will print out "Group: *.720p.HDTV.x264-DIMENSION Tag: giggles*"

This only needs to be run once (or not at all if you set it up yourself) before using the check alias. This creates and saves your hash tables to a file called filter.ini
Code:
alias tables.setup {
  hfree -w group
  hmake group
  hadd group *.720p.HDTV.x264-DIMENSION 1
  hadd group *.720p.HDTV.X264-COMPULSiON 1
  hadd group *.720p.HDTV.X264-2HD 1
  hadd group *.720p.HDTV.x264-EVOLVE 1
  hadd group *.720p.HDTV.x264-ORENJI 1
  
  hfree -w tag
  hmake tag
  hadd tag *giggles* 1
  hadd tag *grins* 1
  hadd tag *laughs* 1
  hadd tag *laughter* 1
  hadd tag *roars* 1
  
  tables.save
}


filter.ini will look as follows
Code:
[group]
*.720p.HDTV.x264-DIMENSION=1
*.720p.HDTV.X264-COMPULSiON=1
*.720p.HDTV.x264-ORENJI=1
*.720p.HDTV.x264-EVOLVE=1
*.720p.HDTV.X264-2HD=1

[tag]
*grins*=1
*laughter*=1
*roars*=1
*laughs*=1
*giggles*=1

Joined: May 2011
Posts: 53
S
Babel fish
OP Offline
Babel fish
S
Joined: May 2011
Posts: 53
Wow, thanks Loki12583 for such a comprehensive reply!

I'm going to try my method and yours running 2 x mirc clients and see if there is a noticeable difference in the 'trigger' time.

I specified '*giggles* iswm $2-4' as the bot string varies 'giggles' between $1, $2, $3 and $4, but never at the beginning or the end of a string.

Can you please confirm if the need to match var %rl anywhere from 4-6 in the announce would work with 'var %rl = $4-6'? Or is there a more effective way to catch the release in $4, $5 or $6?

Thanks smile

Joined: Jan 2004
Posts: 1,361
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,361
There shouldn't be a significant time difference between the two scripts, it's really about good structure and readability.

%rl = $4-6 should work as you're probably given relatively well structured input, but capturing exactly what you want is always better. For that I'd need to see an example of the different lines (or their structures) to construct a proper regex which would extract just the release name.

The group and tag matching above are examples of inclusive filters. If you'd also like to use exclusive filters, you'd do so much in the same way except by inverting the check. Here you could reject text containing any filter you set.

Code:
if (%exclude) && ($hget(exclude,%exclude)) { return }

Last edited by Loki12583; 25/09/12 03:47 PM.
Joined: May 2011
Posts: 53
S
Babel fish
OP Offline
Babel fish
S
Joined: May 2011
Posts: 53
Here's what I'm using right now:

Quote:
if (*giggles* iswm $2-4) || (*grins* iswm $2-4) || (*laughs* iswm $2-4) || (*laughter* iswm $2-4) || (*roars* iswm $2-4) && (*XBOX360-DAGGER* iswm $4-6) || (*XBOX360-iMARS* iswm $4-6) || (*XBOX360-SWAG* iswm $4-6) || (*XBOX360-STRANGE* iswm $4-6) {
var %section = XBOX360
var %rl = $4-6
var %sourcename = SITE1
var %sourcedir = /incoming/x360/
var %curryname = SITE2
var %currydir = /incoming/xbox360/



Would this also work?:

Quote:
if (*giggles*|*grins*|*laughs*|*laughter*|*roars* iswm $2-4) && (*XBOX360-DAGGER*|*XBOX360-iMARS*|*XBOX360-SWAG*|*XBOX360-STRANGE* iswm $4-6) {



Joined: Jan 2004
Posts: 1,361
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,361
The second will not work, you can accomplish this with regex.

Code:
if ($regex($2-4,giggles|grins|laughs|laughter|roars)) && ($regex($4-6,XBOX360-(?:DAGGER|iMARS|SWAG|STRANGE)))


But again, you should be properly parsing the line at the beginning, instead of using $4-6 to guess where it is.

Last edited by Loki12583; 25/09/12 05:30 PM.
Joined: May 2011
Posts: 53
S
Babel fish
OP Offline
Babel fish
S
Joined: May 2011
Posts: 53
Wow, that is clean!

I would say that I'm not exactly guessing as I know the text (which is always the same) will always be $4, $5 or $6. But I see what you mean.

My scripting skills are elementary at best, but at least what I have is actually working!

So with your suggestions I'm going try the following:

Quote:
if ($regex($2-4,giggles|grins|laughs|laughter|roars)) && ($regex($4-6,XBOX360-(?:DAGGER|iMARS|SWAG|STRANGE)))
var %section = XBOX360
var %rl = $4-6
var %sourcename = SITE1
var %sourcedir = /incoming/x360/
var %curryname = SITE2
var %currydir = /incoming/xbox360/


Is there a way to use regex instead of var %rl = $4-6 ?

smile

Joined: Jan 2004
Posts: 1,361
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,361
It depends what the text is, regex is a syntax for matching text. Using capturing groups, you can identify many pieces of text in a given line.

A regex is one method of obtaining the information you want, even though it could be in different $4,5,6 tokens because of spacing. I can't make a regex if you don't give me the text.

Enter the following in your edit box in mIRC, you'll see that it properly isolates and stores the category and show.

Code:
//var %line = Announcement Category: HD TV Shows Show: Arrested Development | noop $regex(%line,Category: (.+?) Show: (.+?)$) | var %category = $regml(1), %show = $regml(2) | echo -ag Category: %category Show: %show

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
To expand on what was said about parsing the text first instead of using $4, $5, and $6...

What determines where the text is located? Is there some word or character that lets you know? For example, let's say that you had these two inputs:

some words-more words-text
word-more words-text

If you wanted "text" each time, you can tell where it is not based on what word it is, but because there are 2 -'s before it. If you can find something specific that can be used to determine whether or not the text is at $4 or $5 or $6 before trying a match on it, your match will be much cleaner.


Invision Support
#Invision on irc.irchighway.net
Joined: May 2011
Posts: 53
S
Babel fish
OP Offline
Babel fish
S
Joined: May 2011
Posts: 53
The problem I'm having is matching the (DIMENSION) release in the bot announce string as it varies between $4 and $6 as shown below:

Quote:
cdc giggles at The.Mindy.Project.S01E01.720p.HDTV.X264-DIMENSION in tv-x264

cdc roars with laughter at NCIS.Los.Angeles.S04E01.720p.HDTV.X264-DIMENSION in tv-x264



So to try and match the release at $4 or $6, I've got 2 entries:


Quote:
if (*giggles* iswm $2) || (*grins* iswm $2) || (*laughs* iswm $2) || (*roars* iswm $2) && (*720p.HDTV.X264-2HD* iswm $4-6) || (*720p.HDTV.X264-COMPULSiON* iswm $4-6) || (*720p.HDTV.x264-DIMENSION* iswm $4-6) || (*720p.HDTV.x264-EVOLVE* iswm $4-6) || (*720p.HDTV.x264-ORENJI* iswm $4-6) {
var %section = TV-X264
var %rl = $replace($4,laughter,$null)


if (*giggles* iswm $2) || (*grins* iswm $2) || (*laughs* iswm $2) || (*roars* iswm $2) && (*720p.HDTV.X264-2HD* iswm $4-6) || (*720p.HDTV.X264-COMPULSiON* iswm $4-6) || (*720p.HDTV.x264-DIMENSION* iswm $4-6) || (*720p.HDTV.x264-EVOLVE* iswm $4-6) || (*720p.HDTV.x264-ORENJI* iswm $4-6) {
var %section = TV-X264
var %rl = $6



The problem is that 'laughter' is still picked up at $4 - and therefore (incorrectly) read as being the release.

Surely there must be an easier way to ensure that the release is matched whether in position $4 or $6 - and that 'laughter' is always ignored?

Joined: Dec 2002
Posts: 344
D
Pan-dimensional mouse
Offline
Pan-dimensional mouse
D
Joined: Dec 2002
Posts: 344
I think this is what you want:

Code:
on $*:ACTION:/^(giggles at|grins at|laughs at|roars with laughter at) (.+) in (.+)$/:#somechannel:{
  if ($nick != cdc) { return }
  var %release = $regml(2), %section = $regml(3)

  ; do stuff here
}


Just modify the list of phrases to include all of the ones that you need to look for.

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
When you use the caret sign in front, you tell regex to only respond when the first word must start with giggles, grins, laughs at, etc...and then end the sentence followed by "in." In other words, the code won't respond if there's any word displayed in front of the triggered phrases.

Joined: Dec 2002
Posts: 344
D
Pan-dimensional mouse
Offline
Pan-dimensional mouse
D
Joined: Dec 2002
Posts: 344
Originally Posted By: Tomao
When you use the caret sign in front, you tell regex to only respond when the first word must start with giggles, grins, laughs at, etc...and then end the sentence followed by "in." In other words, the code won't respond if there's any word displayed in front of the triggered phrases.


Right, I believe that's what the OP actually wanted. Look at the two examples he/she posted in the post immediately before my previous post.


Link Copied to Clipboard