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.

multi lines max text length within time frame

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

also since this is used:

if {[info exists bflood($chan:$nick)]} {

does that mean if it hits 300 in the first line it wont trigger ?
from the looks of it it wont wich kinda defeats the porpose as well
if i read it correctly it would always need a second line to come in existence and start counting
User avatar
grumpy
Voice
Posts: 9
Joined: Fri Jan 10, 2014 3:23 pm
Location: Europe/London

Post by grumpy »

Your right :!: it dosen't actually seem to do anything if they go over the limit the first time around

Code: Select all

set ::bflood(maxlength) 300
set ::bflood(unsettime) 5

bind pub - * pubm:byteflood

proc pubm:byteflood {nick host hand chan text} {

 # ignore if bot not opped, ignore if its a chanop, ignore if the user has +bfmo globally or +fmo for the channel
 if {(![botisop $chan]) || ([isop $nick $chan])} {return}
 if {([validuser $hand]) && ([matchattr $hand +bfmo|fmo $chan])} {return}

 # get the length of the text
 set length [llength $text]

 # ban mask
 set bmask [maskhost "$nick!$host" 2]

 # look up if we have them already in the time limit
 set nick [string tolower $nick]
 set chan [string tolower $chan]
 if {[info exists ::bflood($chan:$nick)]} {

  # increase the count by current length of text
  set ::bflood($chan:$nick) [expr {$::bflood($chan:$nick) + $length}]

  # check they haven't gone over the limit
  if {($::bflood($chan:$nick) > $::bflood(maxlength))} {

   # they have gone over the 'maxlength'
   # devoice them if they are +v
   if {[isvoice $nick $chan]} {pushmode $chan -v $nick}

   # set the ban
   putquick "MODE $chan +b $bmask"

   # unset from array
   unset ::bflood($chan:$nick)

   # finished
   return
  }

  # they haven't gone over the limit, lets set a timer
  utimer $::bflood(unsettime) [list unset ::bflood($chan:$nick)]

  # finished
  return

 # they are within the time limit
 # we start again
 } else {

  # check we haven't already gone over the maxlength
  if {($length => $::bflood(maxlength))} {

   # they have gone over the 'maxlength'
   # devoice them if they are +v
   if {[isvoice $nick $chan]} {pushmode $chan -v $nick}

   # set the ban
   putquick "MODE $chan +b $bmask"

   # end here
   return
  }

  # they are within the limit add to array and unset after ::bflood(unsettime)
  set ::bflood($chan:$nick) $length

  # set a time limit on them
  utimer $::bflood(unsettime) [list unset ::bflood($chan:$nick)]

  # finished
  return
 }
}
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

for this to work at all u need pubm and not pub

i still keep getting errors about errays
Last edited by simo on Sat Jun 20, 2020 8:41 am, edited 1 time in total.
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

this is what i tried so far:

Code: Select all

set ::bflood(maxlength) 300
set ::bflood(unsettime) 5

bind pubm - * pubm:byteflood

proc pubm:byteflood {nick host hand chan text} {

 # ignore if bot not opped, ignore if its a chanop, ignore if the user has +bfmo globally or +fmo for the channel
 if {(![botisop $chan]) || ([isop $nick $chan])} {return}
 if {([validuser $hand]) && ([matchattr $hand +bfmo|fmo $chan])} {return}

 # get the length of the text
 set length [llength $text]

 # ban mask
 set bmask [maskhost "$nick!$host" 2]

 # look up if we have them already in the time limit
 set nick [string tolower $nick]
 set chan [string tolower $chan]
 if {[info exists ::bflood($chan:$nick)]} {

  # increase the count by current length of text
  set ::bflood($chan:$nick) [expr {$::bflood($chan:$nick) + $length}]

  # check they haven't gone over the limit
  if {($::bflood($chan:$nick) > $::bflood(maxlength))} {

   # they have gone over the 'maxlength'
   # devoice them if they are +v
   if {[isvoice $nick $chan]} {pushmode $chan -v $nick}

   # set the ban
   putquick "MODE $chan +b $bmask"

   # unset from array
   unset ::bflood($chan:$nick)

   # finished
   return
  }

  # they haven't gone over the limit, lets set a timer
  utimer $::bflood(unsettime) [list unset ::bflood($chan:$nick)]

  # finished
  return

 # they are within the time limit
 # we start again
 } else {

  # check we haven't already gone over the maxlength
  if {($length >= $::bflood(maxlength))} {

   # they have gone over the 'maxlength'
   # devoice them if they are +v
   if {[isvoice $nick $chan]} {pushmode $chan -v $nick}

   # set the ban
   putquick "MODE $chan +b $bmask"

   # end here
   return
  }

  # they are within the limit add to array and unset after ::bflood(unsettime)
  set ::bflood($chan:$nick) $length

  # set a time limit on them
  utimer $::bflood(unsettime) [list unset ::bflood($chan:$nick)]

  # finished
  return
 }
}
it keeps returning error and doesnt set ban:
Tcl error in script for 'timer111278':
can't unset "::bflood(#test:monnie)": no such element in array
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

also isnt there a way to make each timer unique for each nick instead of having to set many timers per user per line to prevent duplicate timers for the same nick and end up with multiple unsets

so if timer is already running no need to add another one

from what i read this one keeps adding timers while there already is one running if i read correctly
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

if anyone could help with this it would be much apreciated
User avatar
grumpy
Voice
Posts: 9
Joined: Fri Jan 10, 2014 3:23 pm
Location: Europe/London

Post by grumpy »

Code: Select all

  # they haven't gone over the limit, lets set a timer
  utimer $::bflood(unsettime) [list unset ::bflood($chan:$nick)]
try commenting out this line, where it sets an other time after checking for them going over the limit. Should reduce it a bit :oops: hopefully
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

changed it and tested it doesnt trigger no matter the lines of text

this is what im working with so far:

Code: Select all

set ::bflood(maxlength) 300
set ::bflood(unsettime) 5

bind pubm - * pubm:byteflood

proc pubm:byteflood {nick host hand chan text} {

 # ignore if bot not opped, ignore if its a chanop, ignore if the user has +bfmo globally or +fmo for the channel
 if {(![botisop $chan]) || ([isop $nick $chan])} {return}
 if {([validuser $hand]) && ([matchattr $hand +bfmo|fmo $chan])} {return}

 # get the length of the text
 set length [llength $text]

 # ban mask
 set bmask [maskhost "$nick!$host" 2]

 # look up if we have them already in the time limit
 set nick [string tolower $nick]
 set chan [string tolower $chan]
 if {[info exists ::bflood($chan:$nick)]} {

  # increase the count by current length of text
  set ::bflood($chan:$nick) [expr {$::bflood($chan:$nick) + $length}]

  # check they haven't gone over the limit
  if {($::bflood($chan:$nick) > $::bflood(maxlength))} {

   # they have gone over the 'maxlength'
   # devoice them if they are +v
   if {[isvoice $nick $chan]} {pushmode $chan -v $nick}

   # set the ban
   putquick "MODE $chan +b $bmask"

   # unset from array
   unset ::bflood($chan:$nick)

   # finished
   return
  }

  # they haven't gone over the limit, lets set a timer
 # utimer $::bflood(unsettime) [list unset ::bflood($chan:$nick)]

  # finished
  return

 # they are within the time limit
 # we start again
 } else {

  # check we haven't already gone over the maxlength
  if {($length >= $::bflood(maxlength))} {

   # they have gone over the 'maxlength'
   # devoice them if they are +v
   if {[isvoice $nick $chan]} {pushmode $chan -v $nick}

   # set the ban
   putquick "MODE $chan +b $bmask"

   # end here
   return
  }

  # they are within the limit add to array and unset after ::bflood(unsettime)
  set ::bflood($chan:$nick) $length

  # set a time limit on them
  utimer $::bflood(unsettime) [list unset ::bflood($chan:$nick)]

  # finished
  return
 }
}

User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Multi-line Text Flood

Post by SpiKe^^ »

I might try something a little more like this untested code...

Code: Select all

set bflood(maxlength) 300
set bflood(unsettime) 5

bind pubm - * pubm:byteflood

proc pubm:byteflood {nick host hand chan text} {
 global bflood

 if {![botisop $chan] || [isop $nick $chan]} {  return 0  }
 if {[validuser $hand] && [matchattr $hand +bfmo|fmo $chan]} {  return 0  }

 set nick [string tolower $nick]
 set chan [string tolower $chan]

 set length [string length $text]

 if {[info exists bflood($chan:$nick)]} {  incr length $bflood($chan:$nick)  }

 if {($length > $bflood(maxlength))} {

   if {[isvoice $nick $chan]} {  pushmode $chan -v $nick  }

   set bmask [maskhost "$nick!$host" 2]
   putquick "MODE $chan +b $bmask"

   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
}

Last edited by SpiKe^^ on Sat Jun 20, 2020 12:54 pm, edited 1 time in total.
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: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

Excellent tested it and seems to work flawlessly thx SpiKe^^ apreciated as always

and ofcourse grumpy as well thnx for your efforts
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

except for 1 part wich seems to bother me

this part:

Code: Select all


set length [string length $text]

 if {[info exists bflood($chan:$nick)]} {  incr length $bflood($chan:$nick)  }
would that mean if it exists any other nick can increase it rather than each nick to seperatly increase text on their own only
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

No, that should be fine I think.
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: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

my idea would be to check if the one setting the length in

set length [string length $text]

to check if nick is the same nick as the one in $bflood($chan:$nick) and only then to increase
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

It does. Looks fine. But feel free to chop away at the code as you see fit:)
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: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

excellent thanks again SpiKe^^
Post Reply