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.

[SOLVED] Need help on throttled

Help for those learning Tcl or writing their own scripts.
Post Reply
D
Diamond85
Voice
Posts: 27
Joined: Sat Oct 25, 2008 5:12 pm

[SOLVED] Need help on throttled

Post by Diamond85 »

this is from: http://forum.egghelp.org/viewtopic.php?t=9009#45537

Code: Select all

proc throttled {id time} { 
   global throttled 
   if {[info exists throttled($id)]} { 
      return 1 
   } { 
      set throttled($id) [clock sec] 
      utimer $time [list unset throttled($id)] 
      return 0 
   } 
}

example limiting usage by same user@host on a specific channel 
(the id part can be what ever you like of course) 
Code:
bind pub n !test pub:test 
proc pub:test {n u h c a} { 
   if {[throttled $u,$c 30]} { 
      puthelp "PRIVMSG $c :$n: denied. (wait or try a different channel)" 
   } else { 
      puthelp "PRIVMSG $c :$n: allowed (wait 30 seconds)" 
   } 
}
I've got a question times how I can query the seconds that are still open?

if 60 sekungen are set.
wait 35 seconds.
If the user then the commands used. say to the bot may wish to wait 25 seconds.
is that possible?
Last edited by Diamond85 on Fri Dec 21, 2012 8:11 pm, edited 1 time in total.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

try this...

Code: Select all

proc throttled {id time} {
   global throttled
   if {[info exists throttled($id)]} {
      return [expr {($throttled($id)+$time)-[clock sec]}]
   } {
      set throttled($id) [clock sec]
      utimer $time [list unset throttled($id)]
      return 0
   }
}

example limiting usage by same user@host on a specific channel
(the time & id parts can be what ever you like of course)
Code:

bind pub n !test pub:test
proc pub:test {n u h c a} {
   if {[set timeleft [throttled $u,$c 30]]} {
      puthelp "PRIVMSG $c :$n: denied. (wait $timeleft seconds)"
   } else {
      puthelp "PRIVMSG $c :$n: allowed (wait 30 seconds)"
   }
}

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
D
Diamond85
Voice
Posts: 27
Joined: Sat Oct 25, 2008 5:12 pm

Post by Diamond85 »

thank you it works wonderfully!

SpiKe^^ have you a idea what I can do here to make it work?: Link
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Sorry, I know nothing about mysql or the tcl code needed to work it.
SpiKe^^

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