This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Swear Script picking up spaces in this script

Old posts that have not been replied to for several years.
Locked
G
Guest

Post by Guest »

Basicly we have written this swear script for our network , but the bot seems to pick up empty spaces as one of the keywords , it there a way round this ?

bind pubm - * censor

proc censor {nick host hand chan rest } {
global botnick
if { $nick == $botnick } {
return 0
}
set badwords "test1 test2* etc* help"
set saidtxt [lrange $rest 0 end]
set bad_words [split $badwords]
set said_txt [split $saidtxt]
set runningA 1
set detected 0
set said_pos 0
set badlength [llength $bad_words]
set saidlength [llength $said_txt]
while { $runningA == 1 } {
set saidchk [lindex $said_txt $said_pos ]
set slist [join [list $saidchk] ]
set runningB 1
set bad_pos 0
while { $runningB == 1 } {
set badchk [lindex $bad_words $bad_pos ]
set blist [join [list $badchk ] ]
if { [string match $blist $slist] } {
set swearword $slist
set runningA 0
set runningB 0
set detected 1
}
if { $bad_pos == $badlength } {
set runningB 2
} else {
incr bad_pos
}
}
incr said_pos
if { $said_pos == $saidlength } {
set runningA 0
}
}
if { $detected } {
set cenlog [open ./censor/censor.log a+]
puts $cenlog "$nick said $swearword on $chan [time] [date]"
close $cenlog
punish $nick $host $hand $chan
}
return 0
}
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

The script seems overly complex for what its doing and I haven't got time to work out all of it. However this part jumps out at me.
On 2002-02-02 14:51, VampireMan wrote:

set saidtxt [lrange $rest 0 end]
set said_txt [split $saidtxt]
This is wrong. For starters you're using lrange on the string $rest. Secondly, there is never any point to use lrange $string 0 end - its a nullop (unless its used incorrectly as it is here). Type the character { on the channel on its own to see why this is bad (unmached open brace in list). Then you've got an incorretly formed list ($saidtext) which you're putting through split. Why you'd want to do this I don't know (you'd end up with a list within a list). Simply set said_txt [split $rest] should do.
Locked