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.
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
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
[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