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.

adding flood protections to this

Help for those learning Tcl or writing their own scripts.
Post Reply
r
r6gear
Voice
Posts: 3
Joined: Wed Nov 23, 2022 9:28 am

adding flood protections to this

Post by r6gear »

i want to add flood protection to this script. if a user want can user !love !love ...etc and floods the channel.
Can anyoane help me adding ? thank you

bind pub - !love fun_give-love

proc fun_give-love {nick uhost hand chan text} {
putserv "privmsg $chan :\001ACTION Lui 5$nick gives 5$text love!))"
}
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

Code: Select all



# throttle time in seconds
set Xthrottled(time) 10


proc throttlecheckerX {chan} {
  global Xthrottled 
	 if {[info exists Xthrottled($chan)]} {
       return 1
	} else {
		set Xthrottled($chan) [utimer $::Xthrottled(time) [list unset Xthrottled($chan)]]
		return 0
	}
}
 
bind pub - !love fun_give-love

proc fun_give-love {nick uhost hand chan text} {
     if {[throttlecheckerX $chan]} { return 0 }
         set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
         set items [split $text]
     if {[llength $items] < 1 } { putnow "notice $nick :Syntax\: !love nick" ; return }
          set lovenick [lindex [split $text] 0]
         putserv "privmsg $chan :\001ACTION  \002\00305,00 $nick \002\00312 gives \00306\002 $lovenick \002\00307 love \003\017"
}

Last edited by simo on Thu Nov 24, 2022 8:53 am, edited 2 times in total.
User avatar
CrazyCat
Revered One
Posts: 1305
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

@simo : so the command could only be used once every 10s on the chan, whoever use it ?
Why throttlecheckerX has nick as argument if it's not used ?
r
r6gear
Voice
Posts: 3
Joined: Wed Nov 23, 2022 9:28 am

Post by r6gear »

simo wrote:

Code: Select all



# throttle time in seconds
set Xthrottled(time) 10


proc throttlecheckerX {nick chan} {
  global Xthrottled 
	 if {[info exists Xthrottled($chan)]} {
       return 1
	} else {
		set Xthrottled($chan) [utimer $::Xthrottled(time) [list unset Xthrottled($chan)]]
		return 0
	}
}
 
bind pub - !love fun_give-love

proc fun_give-love {nick uhost hand chan text} {
     if {[throttlecheckerX $nick $chan]} { return 0 }
         set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
         set items [split $text]
     if {[llength $items] < 1 } { putnow "notice $nick :Syntax\: !love nick" ; return }
          set lovenick [lindex [split $text] 0]
         putserv "privmsg $chan :\001ACTION  \002\00305,00 $nick \002\00312 gives \00306\002 $lovenick \002\00307 love \003\017"
}

Thank you for helping! !beer
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

That's true i overlooked that thanks for pointing out CrazyCat 👍
r
r6gear
Voice
Posts: 3
Joined: Wed Nov 23, 2022 9:28 am

Post by r6gear »

it's posibile to add a option every user to have let's say 1 shoot every 30 seconds?
User avatar
CrazyCat
Revered One
Posts: 1305
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Just add the nick in the key of Xthrottled. That is what I pointed previously.

Code: Select all

# throttle time in seconds
set Xthrottled(time) 10

proc throttlecheckerX {nick chan} {
   global Xthrottled
   if {[info exists Xthrottled($chan,$nick)]} {
      return 1
   } else {
      set Xthrottled($chan,$nick) [utimer $::Xthrottled(time) [list unset Xthrottled($chan,$nick)]]
      return 0
   }
}
 
bind pub - !love fun_give-love

proc fun_give-love {nick uhost hand chan text} {
     if {[throttlecheckerX $nick $chan]} { return 0 }
         set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
         set items [split $text]
     if {[llength $items] < 1 } { putnow "notice $nick :Syntax\: !love nick" ; return }
          set lovenick [lindex [split $text] 0]
         putserv "privmsg $chan :\001ACTION  \002\00305,00 $nick \002\00312 gives \00306\002 $lovenick \002\00307 love \003\017"
}
Post Reply