mIRC Home    About    Download    Register    News    Help

Print Thread
#249914 22/12/14 07:27 PM
Joined: Aug 2014
Posts: 42
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2014
Posts: 42
Hey i use this badword script:

Code:
on *:LOAD:{
/set %Bannword word1 word2 word3 word4
}

ON @*:TEXT:*:#: {
  IF ($nick !isop #) {
    VAR %i = 0
    WHILE (%i < $numtok(%Bannword,32)) {
      INC %i
      vAR %current.word = $gettok(%Bannword,%i,32)
      IF ($istok($strip($1-),%current.word,32) == $true) {
      msg # .ban $nick
      }
    }
  }
}


The problem i have: when someone write for example "blablaword1" the script dont react, i want that it even react when it find the word in a text! smile

Joined: Dec 2014
Posts: 23
S
Ameglian cow
Offline
Ameglian cow
S
Joined: Dec 2014
Posts: 23
Go ahead in try the isin statement.
/help isin

Joined: Aug 2014
Posts: 42
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2014
Posts: 42
I was thinking about "isin" too but the problem is i dont know what i have to replace, because this script works with tokens and $strip.

Hu..



Last edited by Krawalli; 23/12/14 12:54 AM.
Joined: Jun 2014
Posts: 248
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
Do you really want to ban people for potentially completely pg language?

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Just replace

IF ($istok($strip($1-),%current.word,32) == $true) {

with

if (%current.word isin $strip(1$-)) {

Joined: Aug 2014
Posts: 42
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2014
Posts: 42
Originally Posted By: Sakana
Just replace

IF ($istok($strip($1-),%current.word,32) == $true) {

with

if (%current.word isin $strip(1$-)) {


Not working smirk bot dont react to any badword!

Joined: Jun 2014
Posts: 248
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
if (%current.word isin $strip(1$-)) {
should be
if (%current.word isin $strip($1-)) {

Joined: Aug 2014
Posts: 42
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2014
Posts: 42
Hm 2 strange things:

1.
word1 solo will be timeouted
xyword1 will not timeouted

2.
when someone write a badword the bot timeouts the person 2 times (2x the timeout msg)


/EDIT:
Ok 1. problem fixed, only the 2. "problem" is still there

Last edited by Krawalli; 23/12/14 03:35 AM.
Joined: Jun 2014
Posts: 248
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
I don't think either of those things actually happen.

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
I guess that's because more than 1 bad word was found. Just put a return inside the loop to end the script as soon as it finds a bad word.

Code:
on *:LOAD:{
/set %Bannword word1 word2 word3 word4
}

ON @*:TEXT:*:#: {
  IF ($nick !isop #) {
    VAR %i = 0
    WHILE (%i < $numtok(%Bannword,32)) {
      INC %i
      vAR %current.word = $gettok(%Bannword,%i,32)
      IF (%current.word isin $strip($1-)) {
      msg # .ban $nick
      return
      }
    }
  }
}

Joined: Sep 2014
Posts: 52
Babel fish
Offline
Babel fish
Joined: Sep 2014
Posts: 52
Ok so I modified this to work from an ini file and it seems to be working. My question is, is the on *:TEXT:*:#: portion as efficient as it can be, or can I make it any shorter or more efficient?
Code:
on *:TEXT:!blacklist*:#: {
  if ($nick !isop #) { return }
  var %file blacklist.ini
  if ($2 == add) {
    if ($ini(%file,#,$3) == $null) {
      writeini %file # $3 1
      describe # + $3 has been added to the Blacklist.
    }
    else {
      msg # $3 is already on the Blacklist.
    }
  }
  elseif ($2 == del) {
    if ($ini(%file,#,$3) != $null) {
      remini %file # $3
      describe # - $3 has been removed from the Blacklist.
    } 
    else { 
      msg # Sorry, $3 was not found on the Blacklist.
    }
  }
  else {
    msg # Usage: !blacklist $chr(91) add $chr(124) del $chr(93)
  }
}

on *:TEXT:*:#: {
  if ($nick isop #) { return }
  var %i 1 | while $ini(blacklist.ini,#,%i) {
    var %list %list $v1
    inc %i
  }
  var %j = 0
  while (%j < $numtok(%list,32)) {
    inc %j
    var %words = $gettok(%list,%j,32)
    if (%words isin $strip($1-)) {
      .msg # /timeout $nick 1
      msg # Please don't use blacklisted words/phrases, $nick [Blacklist] [Warning]
      return
    }
  }
}

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
You could use $regex to make it significantly shorter (and decrease processing time... I think?).

Code:
var %wordlist = word1|word2|word3

if ($regex($1-,%wordlist) > 0) { do things }


But you need to use some metacharacters to ignore case sensitivity and other stuff. I'm not sure what the full $regex would have to look like.




Last edited by Sakana; 07/01/15 06:27 AM.

Link Copied to Clipboard