mIRC Home    About    Download    Register    News    Help

Print Thread
#160538 27/09/06 10:16 PM
Joined: Sep 2003
Posts: 261
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
I'd like to have a hash table store the ignore strings like: *!*@blah or blah!*@blah etc...

Using a hash table to store ignore information, what's the best method of using hash tables to check if a nickname is ignored? If a $nick's $address matches one of those stored in the hash table should it be stored as an item or as a data? How would the $hfind work for that?

like:

on 1:text:*:#: {
; if $address matches a string in the hashignore table
if ($address == $hfind(hashingore wildcard stuff here that can match without it really matching) or soemthing?
}

I know mirc stores it's ignore in ini files n0=partorfulladdress,settings,etc... Seems that over time if the list is huge and each time text is spoken it would lag it abit.

Would it need a while loop and some regex to check each line in the hash table for a match. I'm having a hard time thinking this out. Any help appreciated.


We don't just write the scripts, we put them to the test! (ScriptBusters)
#160539 27/09/06 10:58 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Code:
 on ^*:text:*:#:{
  if $hget(ignore,$nick) || $hfind(ignore,$address($nick,5),1).data {
    halt
  }
  else echo $chan $+(<,$nick,>) $1-
}
menu nicklist,channel {
  Add to Ignore : add.ignore $iif($snicks,$snicks,$$?="Nicks to be ignored")
  Remove from Ignore : rem.ignore $iif($snicks,$snicks,$$?="Nicks to be removed")
}
alias add.ignore {
  var %nicks = $replace($1-,$chr(44),$chr(32)), %a = 1, %b = $numtok(%nicks,32)
  while %a <= %b {
    .hadd -m Ignore $gettok(%nicks,%a,32) $iif($address($nick,5),$v1,$false)
    inc %a
  }
}
alias rem.ignore {
  var %nicks = $replace($1-,$chr(44),$chr(32)), %a = 1, %b = $numtok(%nicks,32)
  while %a <= %b {
    .hdel Ignore $gettok(%nicks,%a,32)
    inc %a
  }
}
on *:start:{
  if !$hget(ignore) { .hmake Ignore 10 }
  if $exists(ignore.hsh) { .hload Ignore ignore.hsh }
}
on *:exit:{
  .hsave -o Ignore ignore.hsh
}
on *:disconnect:{
  .hsave -o Ignore ignore.hsh
}
 


I coded this as part of a massive channel control project that I'm working on. It has been tested and does work. If you really want the address to be stored in wildcard format, let me know which mask you want to work with (it's easiest to work with only 1 mask, rather than have to check for all of the possibilities). If you prefer to re-code it yourself, details regarding using wildcards in a hash table can be found under /help $hfind (note the parameter options near the bottom).

#160540 27/09/06 11:04 PM
Joined: Sep 2003
Posts: 261
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
Thanks that should do nicely. smile


We don't just write the scripts, we put them to the test! (ScriptBusters)
#160541 28/09/06 12:50 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Just to explain a bit for you...

You don't need $hfind at all if you're saving the masks as items.

if ($hget(hashtable,mask)) { commands to ignore the person }

Replace hashtable with the name of your hash table and replace mask with however you're getting the mask (such as $address($nick) or $address($nick,2) or whatever).

An example would be:

if ($hget(Ignores,$address($nick)) { commands to ignore }

Because $hget(table,item) will output data if it's there or $null if it's not there, you're basically searching for it with that one command. Here's an expanded version of it that may make more sense...

if ($hget(Ignores,$address($nick) == $null) { commands to ignore }

They mean the same thing in this game (unless your store 0 or $false as the data for a mask). Since you aren't likely to store those as the data for the mask, you don't need the == $null part. To be on the "safe" side, you can include it and then you can store 0 or $false as the data if you want to and it won't make the script not work for that mask.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard