mIRC Home    About    Download    Register    News    Help

Print Thread
anti insults - helpme please #269597 14/11/21 03:09 AM
Joined: Jul 2020
Posts: 11
D
druino Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Jul 2020
Posts: 11
good night I found this anti insult remote and it works very well
Code
on 1:text:*:#: { tokenize 32 $strip($1-)
  if ($me isop $chan ) && ($nick !isop $chan) && ($nick !isvoice $chan) {
  if (perra isin $2-) { ban -ku3600 $chan $nick 2 Vocabulary not allowed in the rules channel }
  if (cibersex isin $2-) { ban -ku3600 $chan $nick 2 Vocabulary not allowed in the rules channel }
  if (striper isin $2-) { ban -ku3600 $chan $nick 2 Vocabulary not allowed in the rules channel }
  }
}


The question is, could you create a set list of insults so just use an isin and anchor it to the list set for example:

Code
set anti-insiltuos {
"perra"
"cybersex"
"striper"
}

on 1:text:*:#: { tokenize 32 $strip($1-)
  if ($me isop $chan ) && ($nick !isop $chan) && ($nick !isvoice $chan) {
    if ($anti-insiltuos isin $2-) { ban -ku3600 $chan $nick 2 Vocabulario no permitido en el canal }
  }
}

I would be very grateful if you could help me to get that variant through a set

Re: anti insults - helpme please [Re: druino] #269604 15/11/21 07:52 AM
Joined: Jan 2004
Posts: 1,640
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,640
What you're asking for is similar to this thread: https://forums.mirc.com/ubbthreads.php/topics/264491/re-bad-word-in-txt-file#Post264491

The problem with your method is that you require a separate if () evaluation for every bad word in the list. Another problem with 'isin' is that it can easily match things it should not, like:

//if (word isin sword) echo -a match

The link shows how using $hfind can accomplish your task much quicker, because there can be 1 function call which matches all badwords against the entire $1- in 1 identifier call. It uses Regex, and while it looks more complicated, you can have much better ability to prevent false matches by having your bad word be required to be a complete word instead of only being a portion of it.

//hadd -m badwords word1 *perra* | hadd badwords word2 *cybersex* | hadd badwords word3 *striper* | echo -a $hfind(badwords,foo perra bar,1,W).data

This is a quick example where $hfind can compare all words in your list at the same time against $1-

For this to work, you can create a hashtable where the itemname is a unique word, it doesn't matter what it is, and the data is where you put the badword as a wildcard string. The capital W switch means that the wildcard string is in the hashtable, and using the .data makes it try to match the data instead of the itemname.

The hashtable lives in memory, so it disappears when you quit mirc, unless you save it to disk like

/hsave -s badwords badwords.txt

... and the next time you start mirc, you can either use the commands above to re-make the bad word list, or you can load the list off disk like:

/hload -s badwords badwords.txt

I could have made the badword be the itemname instead of the data, but that would not allow you to have the badword be a string of several words.

In my example, $hfind returned the item name where the data contained the bad word. If word1 is returned by $hfind, you can use $hget(badword,word1) to see what the match found.