| View previous topic :: View next topic |
| Author |
Message |
Way2Death Voice
Joined: 31 Mar 2009 Posts: 15
|
Posted: Mon Apr 06, 2009 8:59 am Post subject: [SOLVED] Excessive command use |
|
|
He this should be simple, but i cant seem to find the right keyword to search it....
how would i set a lock on my command to prevent it from over using,
like if you type
!show
!show
you would get : Please wait at least 5 minutes to re-use this command
Last edited by Way2Death on Tue Apr 07, 2009 2:21 pm; edited 1 time in total |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Mon Apr 06, 2009 9:37 am Post subject: |
|
|
| Code: |
set vFlood [expr {[unixtime] - 300}]
bind PUB - !show pShow
proc pShow {nick uhost hand channel txt} {
global vFlood
if {[expr {[unixtime] - $vFlood}] > 299} {
set vFlood [unixtime]
# your code here
} else {putserv "PRIVMSG $channel :sorry $nick, there is a 5 minute wait between successive uses of the command !show"}
return 0
}
|
_________________ I must have had nothing to do |
|
| Back to top |
|
 |
Way2Death Voice
Joined: 31 Mar 2009 Posts: 15
|
Posted: Mon Apr 06, 2009 9:40 am Post subject: |
|
|
| All right thanks, so what is this called? Excessive command use? |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Mon Apr 06, 2009 9:46 am Post subject: |
|
|
It doesn't have a specific name. It is simply one method of preventing overuse of a command. Command flood control I suppose you could say.
btw I have edited the code a little, be sure to reread it
In plain english, the command will only trigger if the last time it was used is more than 299 seconds ago (or if the bot was just rehashed/restarted). _________________ I must have had nothing to do
Last edited by arfer on Mon Apr 06, 2009 9:50 am; edited 1 time in total |
|
| Back to top |
|
 |
Way2Death Voice
Joined: 31 Mar 2009 Posts: 15
|
Posted: Mon Apr 06, 2009 9:49 am Post subject: |
|
|
| arfer wrote: | | It doesn't have a specific name. It is simply one method of preventing overuse of a command. Command flood control I suppose you could say. |
All right, thanks so much =D i appreciate the help! |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon Apr 06, 2009 12:18 pm Post subject: |
|
|
I believe the most common term is "throttling".
I recall user posted a nice proc (function) called "throttled" a long time ago, to make it simple to add such checks to any code. A quick search in the forum would probably reveal it. (arfer's code should do the trick just as well). _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|