Skip to content
MSN

Alias help needed

A TG007 community discussion started by Warrior124.

Discussion 10 posts
Page 1 of 1
Open
Topic #3139 · 10 published posts · 966 views

The alias I have is suppose to block words from echoing to the script. It stops it if the word from the blocked words text is anywhere from the second word on in the message. However, if it is the first word it doesn't block it, and I was wondering if someone can help me with this? Here is the code I have...

 

alias words {
 if (%blockwords != $true) { return $1- }
 else { 
   var %words = $1-
   var %x = 1, %i = $lines(blockwords.txt)
   while (%x <= %i) {
     var %wd = $read(blockwords.txt,%x)
     if (%words > %wd) { return }
     else { return %words }
     inc %x
   }
 }
}

are you using it like $words($1-) in the echo ?

My code does NOT have bugs. It just develops random features.

Yes, I am

 

Where you have (%words > %wd) that's bascially "if this sentence is greater than that sentence" - you can't use greater than with anything other than digits. Also, the return wouldn't do anything.

alias words {
 if (%blockwords != $true) { return $1- }
 else { 
   var %words = $1-
 ;I've added %tt to have a list of bad words, rather than just one
   var %x = 1, %i = $lines(blockwords.txt), %tt = $chr(36)
   while (%x <= %i) {
     var %wd = $read(blockwords.txt,%x)
   ;if it's not there, continue with the loop, if it is, add it to the list
     if (%wd !isin %words) { inc %x }
     else { var %tt = %tt $+ , %wd | inc %x }
   }
 ;Lastly, it returns the full list of bad words
   return $remove(%tt,$chr(36))
 }
}

Edited Mar 18, 2005 11:38 AM by Cleric xtx

 

Thanks for the code. However, it is returning all nulls now. Even from the words that isn't in the blocked words list.

Edited Mar 18, 2005 11:52 AM by Warrior124

would be much easier using an ini file

 

anyway , this is tried and tested, just make sure the script and the blocked words text are in same dir

 

on *:TEXT:*:#: { echo -a $words($1-) }
alias words {
 var %x = 1
 while (%x <= $lines($scriptdir $+ blockwords.txt)) {
   if ($read($scriptdir $+ blockwords.txt,%x) !isin $1-) && (%x == $lines($scriptdir $+ blockwords.txt)) { return $1- | break }
   if ($read($scriptdir $+ blockwords.txt,%x) isin $1-) { return the message has been blocked as it contained profanity | break }
   inc %x
 }
}

Edited Mar 18, 2005 1:22 PM by OZZY_10â„¢

My code does NOT have bugs. It just develops random features.

Thanks, Ozzy_10. It works now.

yw , but it is easier to use an .ini file to do that lol

My code does NOT have bugs. It just develops random features.

if it was me i would do it this way

 

on *:TEXT:*:#: echo -a $words($1-)
alias words { var %x = 1 | while ($read($scriptdir $+ blockwords.txt,%x)) { if ($ifmatch isin $1-) { return the message has been blocked as it contained profanity | break } | inc %x } | return $1- } 

Edited Mar 19, 2005 7:56 AM by The Gate Keeper

yup that also works , but i was trying to do it how he was allready attemting to do it , so he learnt the way he was allready trying.

But all is good

My code does NOT have bugs. It just develops random features.