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.
Help for those learning Tcl or writing their own scripts.
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Mar 05, 2022 9:35 am
im struggling to find a solution for this small tcl counting text characters
till reaching threshold for some reason if nick is like [somenick] it reaches threshold with few characters not even reached the set bflood(maxlength) 200 threshold
im not sure how to fix this issue
Code: Select all
set bflood(maxlength) 200
set bflood(unsettime) 4
bind pubm - * pubm:byteflood
proc pubm:byteflood {nick host hand chan text} {
global bflood
if {[string match -nocase #help $chan]} { return 0 }
set chan [string tolower $chan]
set text [string map [list \017 ""] [stripcodes abcgru $text]]
set text [split $text]
set length [string length [regsub -all {\ } $text ""]]
if {[info exists bflood($chan:$nick)]} { incr length $bflood($chan:$nick) }
if {($length >= $bflood(maxlength))} {
set bmask [maskhost "$nick!$host" 2]
after [expr {5*1000*1}] [list pushmode2 $chan -b m:$bmask]
pushmode $chan +b m:$bmask
putnow "NOTICE $nick Mass Text Detected"
array unset bflood $chan:$nick
return 0
}
if {![info exists bflood($chan:$nick)]} {
utimer $bflood(unsettime) [list array unset bflood $chan:$nick]
}
set bflood($chan:$nick) $length
return 0
}
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Sat Mar 05, 2022 6:25 pm
Try this code,
.restart the bot to clear global vars
Code: Select all
set bflood(maxlength) 200
set bflood(unsettime) 4
bind pubm - * pubm:byteflood
proc pubm:byteflood {nick host hand chan text} {
global bflood
if {[string match -nocase #help $chan]} { return 0 }
set chan [string tolower $chan]
set text [string map [list \017 ""] [stripcodes abcgru $text]]
set length [string length [regsub -all {\ } $text ""]]
if {[info exists bflood($chan:$nick)]} { incr length $bflood($chan:$nick) }
if {($length >= $bflood(maxlength))} {
set bmask [maskhost "$nick!$host" 2]
after [expr {5*1000*1}] [list pushmode2 $chan -b m:$bmask]
pushmode $chan +b m:$bmask
putnow "NOTICE $nick Mass Text Detected"
unset -nocomplain bflood($chan:$nick)
return 0
}
if {![info exists bflood($chan:$nick)]} {
utimer $bflood(unsettime) [list unset -nocomplain bflood($chan:$nick)]
}
set bflood($chan:$nick) $length
return 0
}
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Mar 05, 2022 9:12 pm
thanks spike^ ive tested it and so far seems to work as expected i will minitor it some more in an active channel and get back to ya hopefully
thanks again.