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 

multi lines max text length within time frame
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
simo
Owner


Joined: 22 Mar 2015
Posts: 894

PostPosted: Fri Jun 19, 2020 4:18 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
grumpy
Voice


Joined: 10 Jan 2014
Posts: 9
Location: Europe/London

PostPosted: Sat Jun 20, 2020 6:17 am    Post subject: Reply with quote

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

Code:
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
 }
}
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 894

PostPosted: Sat Jun 20, 2020 8:20 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 894

PostPosted: Sat Jun 20, 2020 8:27 am    Post subject: Reply with quote

this is what i tried so far:

Code:

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:

Quote:

Tcl error in script for 'timer111278':
can't unset "::bflood(#test:monnie)": no such element in array

Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 894

PostPosted: Sat Jun 20, 2020 8:34 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 894

PostPosted: Sat Jun 20, 2020 8:44 am    Post subject: Reply with quote

if anyone could help with this it would be much apreciated
Back to top
View user's profile Send private message
grumpy
Voice


Joined: 10 Jan 2014
Posts: 9
Location: Europe/London

PostPosted: Sat Jun 20, 2020 9:52 am    Post subject: Reply with quote

Code:
  # 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 Embarassed hopefully
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 894

PostPosted: Sat Jun 20, 2020 11:11 am    Post subject: Reply with quote

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

this is what im working with so far:

Code:

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
 }
}

Back to top
View user's profile Send private message
SpiKe^^
Owner


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

PostPosted: Sat Jun 20, 2020 12:07 pm    Post subject: Multi-line Text Flood Reply with quote

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

Code:

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
}


_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.


Last edited by SpiKe^^ on Sat Jun 20, 2020 12:54 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 894

PostPosted: Sat Jun 20, 2020 12:34 pm    Post subject: Reply with quote

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

and ofcourse grumpy as well thnx for your efforts
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 894

PostPosted: Sat Jun 20, 2020 1:09 pm    Post subject: Reply with quote

except for 1 part wich seems to bother me

this part:

Code:


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


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

PostPosted: Sat Jun 20, 2020 1:12 pm    Post subject: Reply with quote

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


Joined: 22 Mar 2015
Posts: 894

PostPosted: Sat Jun 20, 2020 1:22 pm    Post subject: Reply with quote

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


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

PostPosted: Sat Jun 20, 2020 1:26 pm    Post subject: Reply with quote

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


Joined: 22 Mar 2015
Posts: 894

PostPosted: Sat Jun 20, 2020 1:35 pm    Post subject: Reply with quote

excellent thanks again SpiKe^^
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 -> Script Requests All times are GMT - 4 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
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