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 

[SOLVED] Need help on throttled

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


Joined: 25 Oct 2008
Posts: 27

PostPosted: Fri Dec 21, 2012 1:17 pm    Post subject: [SOLVED] Need help on throttled Reply with quote

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

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


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

PostPosted: Fri Dec 21, 2012 5:11 pm    Post subject: Reply with quote

try this...
Code:

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


Joined: 25 Oct 2008
Posts: 27

PostPosted: Fri Dec 21, 2012 7:15 pm    Post subject: Reply with quote

thank you it works wonderfully!

SpiKe^^ have you a idea what I can do here to make it work?: Link
Back to top
View user's profile Send private message
SpiKe^^
Owner


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

PostPosted: Fri Dec 21, 2012 8:15 pm    Post subject: Reply with quote

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