egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

text character counter issue with nick like [somenick]

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sat Mar 05, 2022 9:35 am    Post subject: text character counter issue with nick like [somenick] Reply with quote

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
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Sat Mar 05, 2022 6:25 pm    Post subject: Try this. Reply with quote

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
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sat Mar 05, 2022 9:12 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber