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] Excessive command use

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


Joined: 31 Mar 2009
Posts: 15

PostPosted: Mon Apr 06, 2009 8:59 am    Post subject: [SOLVED] Excessive command use Reply with quote

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
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Mon Apr 06, 2009 9:37 am    Post subject: Reply with quote

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
View user's profile Send private message
Way2Death
Voice


Joined: 31 Mar 2009
Posts: 15

PostPosted: Mon Apr 06, 2009 9:40 am    Post subject: Reply with quote

All right thanks, so what is this called? Excessive command use?
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Mon Apr 06, 2009 9:46 am    Post subject: Reply with quote

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
View user's profile Send private message
Way2Death
Voice


Joined: 31 Mar 2009
Posts: 15

PostPosted: Mon Apr 06, 2009 9:49 am    Post subject: Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon Apr 06, 2009 12:18 pm    Post subject: Reply with quote

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
View user's profile Send private message
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