|
Joined: Jul 2003
Posts: 655
Fjord artisan
|
OP
Fjord artisan
Joined: Jul 2003
Posts: 655 |
as the topic suggests i wrote this to block annoying messages such as timed aways, spam, auto thank you scripts etc #msgblock off
on ^*:OPEN:?: { set %opn 0 }
on ^*:TEXT:*:*: { if ($chan) { blocker 1 $1- } | else { blocker 2 $1- } }
on ^*:ACTION:*:*: { if ($chan) { blocker 3 $1- } | else { blocker 4 $1- } }
on ^*:NOTICE:*:*: { if ($chan) { blocker 5 $1- } | else { blocker 6 $1- } }
ctcp *:*:*: { if ($chan) { blocker 7 $1- } | else { blocker 8 $1- } }
alias -l blocker {
var %x = 1
while (%x <= $ini($block.s, blocks, 0)) {
if ($ini($block.s, blocks, %x) iswm $2-) && ($gettok($readini($block.s, blocks, $ini($block.s, blocks, %x)), $1, 124) == 1) {
echo -sn $timestamp Block DEBUG :: entry %x :: match $ini($block.s, blocks, %x) :: tok $1 :: $2- ( $+ $gettok($readini($block.s, blocks, $ini($block.s, blocks, %x)), 9, 124) $+ )
if (%opn == 0) { close -m $nick | unset %opn }
haltdef
halt
}
inc %x
}
unset %opn
}
alias -l block.s { return $scriptdirmsgblock.set }
#msgblock end format of ini file..... wildcard=text#|text?|action#|action?|notice#|notice?|ctcp#|ctcp?|note eg - [blocks] *mp3*=0|0|0|0|0|0|1|0|Mp3srvCtcp *slots*=0|0|0|0|0|0|1|0|Mp3srvCtcp *<<*{{*Voice*}}*>>*=1|0|0|0|0|0|0|0|ExAutoAck Obviously the event handling could be improved somewhat, but for now, as you can imagine, the issue is lag. I've not done a great deal of testing but just from reading the code i am sure you can see how this would create personal lag in mirc if in large and active channels and/or with a large list of wildcards to check through. There has got to be a more efficient way to do this, any ideas?
"Allen is having a small problem and needs help adjusting his attitude" - Flutterby
|
|
|
|
Joined: Dec 2002
Posts: 774
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 774 |
Accessing files is slow...
Start using hashtables...
//if ( khaled isgod ) echo yes | else echo no
|
|
|
|
Joined: Jul 2003
Posts: 655
Fjord artisan
|
OP
Fjord artisan
Joined: Jul 2003
Posts: 655 |
hmm, thanks, time to learn has tables in mirc i guess heh.
How much of a difference would it make? filters like the above would still have to be stored in an external file, so why would accessing an external hash file be quicker than accessing an external ini file? maybe i dont quite understand how a hash file is compared to a normal file?
"Allen is having a small problem and needs help adjusting his attitude" - Flutterby
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
a hashtable he said not a hashfile (whats a hashfile? lol)
im assuming you mean a hashfile is a saved hashtable, if so then u only access that once to load it then its loaded and the script just uises it from then on.
|
|
|
|
Joined: Dec 2002
Posts: 774
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 774 |
Hash tables are in memory. You need to make only one file operation when you start mIRC.
on start event: Create "blocks" hash table with /hmake Load blocks from file to "blocks" -hash table with /hload as it supports ini files you don't have to anything to the file structure.
on text & others: Use $hfind, it has the ability to match the item name which is wildmark text to a specified text You should end up with something like this $hfind(blocks,$2-,1,W) RED: Hash Table name GREEN: Text to match BLUE: 1st found item to be retrieved BLACK: W switch that specifies that the item name in the hash table is wildmask. $hfind returns item name so use that in $hget to return the item contents
then just do the checking as you've done this far...
Maybe you should also change the list from tokens to just plain text ie. 01001000comment as you can retrieve the 0s and 1s with $mid(00010000comments etc,$1,1) and comments with $right(00110011comments plaaplaa,-8)
If you don't have a clue of what I'm trying to say just look these up from help file...
//if ( khaled isgod ) echo yes | else echo no
|
|
|
|
Joined: Jul 2003
Posts: 655
Fjord artisan
|
OP
Fjord artisan
Joined: Jul 2003
Posts: 655 |
DaveC, yes i meant a saved hash table
theRat, thanks i do understand, i had an idea of what hash tables were and i did go ahead and read the help already. I see why it would be quicker, i was unaware how hash tables were loaded into mirc.
And yeah i know using tokens is not the best method, but it was just something quickly put together before i realised the problem using an ini file and while loop would create.
Umm, the /hmake will overwrite existing hash table if it exists correct? (for use with a settings/filter list dialog) so that it can be updated on save.
"Allen is having a small problem and needs help adjusting his attitude" - Flutterby
|
|
|
|
Joined: Dec 2002
Posts: 1,922
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,922 |
Nope, /hmake will fail if the table exists. If you call it from the "on start" event, you don't have to worry about existing tables because there are none.
|
|
|
|
Joined: Jul 2003
Posts: 655
Fjord artisan
|
OP
Fjord artisan
Joined: Jul 2003
Posts: 655 |
Okay, so there are i guess two methods i could use for implementing any changes.
have the dialog interact with the ini file, then upon saving and exiting the dialog use /hfree then /hmake and /hload to make sure all is up to date, or, have the dialog interact with the hash table itself using /hdel /hadd (for adding, removing and editing filters) and $hget (for loading the filter list to the dialog and retrieving any information needed when editing a filter), then upon saving and exiting the dialog use /hsave -o to save the settings externally.
Think im getting the idea heh, Thanks for the info and help guys.
"Allen is having a small problem and needs help adjusting his attitude" - Flutterby
|
|
|
|
Joined: Nov 2003
Posts: 2,327
Hoopy frood
|
Hoopy frood
Joined: Nov 2003
Posts: 2,327 |
just FYI, in future when you use hashtables, if you don't need to save the hashtable when you exit, then you won't need to load it on start, so that also means you won't need to use /hmake, you can use /hadd -m instead
New username: hixxy
|
|
|
|
|