mIRC Home    About    Download    Register    News    Help

Print Thread
#29022 10/06/03 05:36 PM
Joined: Apr 2003
Posts: 300
A
andymps Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Apr 2003
Posts: 300
how do u get it to identify a word from a sentance and if that word is in a txt file?


Liek OMG Yuo Stoleded my MageHurtzzzz!!!11
#29023 10/06/03 05:44 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
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.


-KingTomato
#29024 10/06/03 05:46 PM
Joined: Apr 2003
Posts: 300
A
andymps Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Apr 2003
Posts: 300
Thnax again KT smile


Liek OMG Yuo Stoleded my MageHurtzzzz!!!11
#29025 10/06/03 06:08 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
np >:D


-KingTomato
#29026 10/06/03 06:33 PM
Joined: Apr 2003
Posts: 300
A
andymps Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Apr 2003
Posts: 300
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


Liek OMG Yuo Stoleded my MageHurtzzzz!!!11
#29027 10/06/03 06:57 PM
Joined: Dec 2002
Posts: 169
J
Vogon poet
Offline
Vogon poet
J
Joined: Dec 2002
Posts: 169
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.

#29028 10/06/03 07:02 PM
Joined: Apr 2003
Posts: 300
A
andymps Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Apr 2003
Posts: 300
That what it is it like
Code:
 
S***T
F***K

and like that with out the stars


Liek OMG Yuo Stoleded my MageHurtzzzz!!!11
#29029 10/06/03 07:04 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
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


-KingTomato
#29030 10/06/03 07:07 PM
Joined: Apr 2003
Posts: 300
A
andymps Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Apr 2003
Posts: 300
Yeah i had a look at that and its not realy what im lookin for so i decided to try my own


Liek OMG Yuo Stoleded my MageHurtzzzz!!!11
#29031 10/06/03 07:10 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Well i made an update. It now uses a dialog, not a popup. Much easier to edit and alter words and their actions


-KingTomato
#29032 10/06/03 07:10 PM
Joined: Dec 2002
Posts: 169
J
Vogon poet
Offline
Vogon poet
J
Joined: Dec 2002
Posts: 169
Ok, another stupid question. Is the swear word file in the same directory as the script?

#29033 10/06/03 07:14 PM
Joined: Apr 2003
Posts: 300
A
andymps Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Apr 2003
Posts: 300
hehe yes it is


Liek OMG Yuo Stoleded my MageHurtzzzz!!!11
#29034 10/06/03 07:37 PM
Joined: Dec 2002
Posts: 169
J
Vogon poet
Offline
Vogon poet
J
Joined: Dec 2002
Posts: 169
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
  }
}

#29035 10/06/03 07:55 PM
Joined: Apr 2003
Posts: 300
A
andymps Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Apr 2003
Posts: 300
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

Last edited by andymps; 10/06/03 08:34 PM.

Liek OMG Yuo Stoleded my MageHurtzzzz!!!11
#29036 10/06/03 08:54 PM
Joined: Dec 2002
Posts: 169
J
Vogon poet
Offline
Vogon poet
J
Joined: Dec 2002
Posts: 169
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.

#29037 11/06/03 09:04 AM
Joined: Dec 2002
Posts: 191
N
Vogon poet
Offline
Vogon poet
N
Joined: Dec 2002
Posts: 191
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.

#29038 11/06/03 09:23 AM
Joined: Dec 2002
Posts: 169
J
Vogon poet
Offline
Vogon poet
J
Joined: Dec 2002
Posts: 169
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


Link Copied to Clipboard