| View previous topic :: View next topic |
| Author |
Message |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Sat Mar 05, 2022 9:35 am Post subject: text character counter issue with nick like [somenick] |
|
|
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: |
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
} |
|
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Sat Mar 05, 2022 6:25 pm Post subject: Try this. |
|
|
Try this code,
.restart the bot to clear global vars
| Code: |
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
}
|
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Sat Mar 05, 2022 9:12 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
|