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.

text character counter issue with nick like [somenick]

Help for those learning Tcl or writing their own scripts.
Post Reply
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

text character counter issue with nick like [somenick]

Post by simo »

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
}
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Try this.

Post by SpiKe^^ »

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
}

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

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.
Post Reply