mIRC Homepage
Posted By: andymps Identifying a word - 10/06/03 05:36 PM
how do u get it to identify a word from a sentance and if that word is in a txt file?
Posted By: KingTomato Re: Identifying a word - 10/06/03 05:44 PM
Code:
on 1:TEXT:*:#: {
  /unset %match
  var %word = 1
  while (%word <= $numtok($1-, 32)) {
    if ($read([color:Red]yourtext.txt[/color], s, $gettok($1-, %word, 32))) var %match = $addtok(%match, $gettok($1-, %word, 32), 44)
    /inc %word
  }
  if (%match != $null) /msg $chan Found the current matching words: %match
}


that will output all matching words form the message in the channel. From there, either alter the "if($read(..." command to whatever you'd like, and remove the msg command.
Posted By: andymps Re: Identifying a word - 10/06/03 05:46 PM
Thnax again KT smile
Posted By: KingTomato Re: Identifying a word - 10/06/03 06:08 PM
np >:D
Posted By: andymps Re: Identifying a word - 10/06/03 06:33 PM
right i have done this:
Code:
 
on @1:TEXT:*:#botsparadise: {  
  /unset %match  
  var %word = 1  
  while (%word <= $numtok($1-, 32)) {  
    if ($read(swearwords.txt, s, $gettok($1-, %word, 32))) var %match = $addtok(%match, $gettok($1-, %word, 32), 44)    
    /inc %word 
  }  
  if (%match != $null) /msg $chan Do not use: < $+ $nick $+ > " $+ %match $+ " You will be kicked if it happens again | /write swearer.txt $nick
}
 

it doesnt work can u spot what is worng
Posted By: Jerk Re: Identifying a word - 10/06/03 06:57 PM
Can you show us a snippet of your swearwords.txt file?

$read(file,s,word) scans for lines beginning with that word. Your text file needs to have each swear on an individual line.
Posted By: andymps Re: Identifying a word - 10/06/03 07:02 PM
That what it is it like
Code:
 
S***T
F***K

and like that with out the stars
Posted By: KingTomato Re: Identifying a word - 10/06/03 07:04 PM
Well, i made a swear detection system that ises a hash table if you are interested. You can set how harsh youd like the action to be taken, and what words yo add. Find it at: http://www.kingtomato.com/files/swearing.zip
Posted By: andymps Re: Identifying a word - 10/06/03 07:07 PM
Yeah i had a look at that and its not realy what im lookin for so i decided to try my own
Posted By: KingTomato Re: Identifying a word - 10/06/03 07:10 PM
Well i made an update. It now uses a dialog, not a popup. Much easier to edit and alter words and their actions
Posted By: Jerk Re: Identifying a word - 10/06/03 07:10 PM
Ok, another stupid question. Is the swear word file in the same directory as the script?
Posted By: andymps Re: Identifying a word - 10/06/03 07:14 PM
hehe yes it is
Posted By: Jerk Re: Identifying a word - 10/06/03 07:37 PM
Bah, $read(file,s,word) returns all the text AFTER word. Check $readn instead.
Code:
on @1:TEXT:*:#botsparadise: {  
  var %i = 1 
  while (%i <= $0) {
    .!echo -q $read($scriptdirswearwords.txt,s,$eval($+($,%i),2))
    if ($readn) { var %match = $addtok(%match,$eval($+($,%i),2),44) } 
    inc %i
  } 
  if (%match != $null) { 
    msg $chan Do not use: < $+ $nick $+ > " $+ %match $+ " You will be kicked if it happens again
  }
}
Posted By: andymps Re: Identifying a word - 10/06/03 07:55 PM
ok then done that also i have added a few things will they work
Code:
 
on @1:TEXT:*:#botsparadise: {   
  var %i = 1   
  while (%i <= $0) {    
    .!echo -q $read($scriptdirswearwords.txt,s,$eval($+($,%i),2))    
    if ($readn) { var %match = $addtok(%match,$eval($+($,%i),2),44) }     
    inc %i  
  }   
 [color:red]     if ($read(swearers.txt,s,$nick) && if($nick !isop #)) {
    if ($ifmatch != $null) {
      kick $chan $nick You Were Warned   
      elseif (%match != $null) {  
[/color]        msg $chan Do not use: < $+ $nick $+ > " $+ %match $+ " You will be kicked if it happens again  | write swearers.txt $nick
      }
    }
  }
}

 

cos i need it to make sur it doesnt do anythin to the ops and if the persons nick is in a txt file it will kick them
Posted By: Jerk Re: Identifying a word - 10/06/03 08:54 PM
I would put "if ($nick !isop $chan)" at the top so it skips the entire thing if the person is opped.

You also need to put an "if (%match) {" in there.
Code:
on @1:TEXT:*:#botsparadise: {   
  if ($nick !isop $chan) {
    tokenize 32 $strip($1-)
    var %i = 1   
    while (%i <= $0) {    
      .!echo -q $read($scriptdirswearwords.txt,s,$eval($+($,%i),2))    
      if ($readn) { var %match = $addtok(%match,$eval($+($,%i),2),44) }     
      inc %i  
    }   
    ; You need this so you don't take any action of no swears were spoke by $nick
    if (%match) {
      .!echo -q $read($scriptdirswearers.txt,s,$nick)
      if ($readn) { kick $chan $nick You Were Warned } 
      else {  
        msg $chan Do not use: < $+ $nick $+ > " $+ %match $+ " You will be kicked if it happens again 
        write $scriptdirswearers.txt $nick
      }
    }
  }
}
Personally, I would use a hash table for both the swear word file and to keep track of who triggered it. Otherwise you have to at some time clean up swearers.txt. Also, if the person switches nicks then they will get away with a warning instead of a kick. Here is a sample script that uses a hash table to store who has sworn.
Code:
on @1:TEXT:*:#botsparadise: { 
  if ($nick !isop $chan) {  
    tokenize 32 $strip($1-)
    var %i = 1   
    while (%i <= $0) {    
      .!echo -q $read($scriptdirswearwords.txt,s,$eval($+($,%i),2))
      if ($readn) { var %match = $addtok(%match,$eval($+($,%i),2),44) }     
      inc %i  
    }   
    if (%match) {
      if ($hget(SwearKicked) == $null) { hmake SwearKicked 100 }
      if ($hfind(SwearKicked,$fulladdress,1,W)) {
        var %item = $ifmatch , %val = $hget(SwearKicked,%item)
        if (%val > 5) { ban $chan $nick 2 | kick $chan $nick You were warned %val times!  Now you are banned! }
        else { kick $chan $nick You were warned %val time $+ $iif(%val > 1,s) $+ ! }
        hinc -u7200 SwearKicked %item 1
      }
      else {
        hadd -u7200 SwearKicked $+(*!*,$address) 1
        msg $chan Do not use: < $+ $nick $+ > " $+ %match $+ " You will be kicked if it happens again
      }
    }
  }
}
It will add their address to a hash table (to avoid people escaping by changing nicks) and each entry will expire after 2 hours. It will warn with a msg the first time, kick after warnings 1-5, and ban the user after.
Posted By: Nobodi Re: Identifying a word - 11/06/03 09:04 AM
Quote:

$read(file,s,word) scans for lines beginning with that word. Your text file needs to have each swear on an individual line.


As long as there is more than one word in the line it will return the rest of the line less the text you uesd as the matchtext, by using $read(file,w,word) it will still return the line even when the line only has the one word.
Posted By: Jerk Re: Identifying a word - 11/06/03 09:23 AM
Ah yes. I didn't think to use the w option without any wildcards. That makes it a line or so smaller.
Code:
      .!echo -q $read($scriptdirswearwords.txt,s,$eval($+($,%i),2))
      if ($readn) { var %match = $addtok(%match,$eval($+($,%i),2),44) }
to
Code:
if ($read($scriptdirswearwords.txt,w,$eval($+($,%i),2))) { var %match = $addtok(%match,$ifmatch,44) } 
In case the original poster is still watching this thread
© mIRC Discussion Forums