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 

Throttling

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


Joined: 25 Jun 2008
Posts: 4

PostPosted: Sun Feb 06, 2011 1:31 pm    Post subject: Throttling Reply with quote

I've read may of the topics concerning throttling

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
   }
}
 


and I can apply it to more basic commands, but am unsure of where to place this part of the code within the following....

if {[throttled $host,$chan 10]} {
return 0
} else {

arfer wrote:
Code:

foreach dayname {sunday monday tuesday wednesday thursday friday saturday} {
    bind PUB - !$dayname [list pDailySchedule $dayname]
}

proc pDailySchedule {dayname nick uhost hand chan text} {
    if {[file exists ${dayname}.txt]} {
        set id [open ${dayname}.txt r]
        set schedule [split [read -nonewline $id] \n]
        close $id
        if {[llength $schedule] != 0} {
            putserv "PRIVMSG $chan :Schedule for [string totitle $dayname]"
            foreach item $schedule {
                putserv "PRIVMSG $chan :$item"
            }
        } else {putserv "PRIVMSG $chan :There are no scheduled events for [string totitle $dayname]"}
    } else {putserv "PRIVMSG $chan :Missing file ${dayname}.txt"}
    return 0
}


If someone could give me a heads up, it would be appreciated Smile
Back to top
View user's profile Send private message
TCL_no_TK
Owner


Joined: 25 Aug 2006
Posts: 509
Location: England, Yorkshire

PostPosted: Wed Feb 09, 2011 2:45 am    Post subject: Reply with quote

Just add it to this proc
Code:
proc pDailySchedule {dayname nick uhost hand chan text} {
    if {[file exists ${dayname}.txt]} {
like so
Code:
proc pDailySchedule {dayname nick uhost hand chan text} {
    if {[throttled $uhost,$chan 10]} {
     putlog "* throttled: waiting 10 seconds.... (public command: !$dayname)"
     return
    }
    if {[file exists ${dayname}.txt]} {
Smile
_________________
TCL the misunderstood
Back to top
View user's profile Send private message Send e-mail
padyo
Voice


Joined: 25 Jun 2008
Posts: 4

PostPosted: Thu Feb 10, 2011 9:05 am    Post subject: Reply with quote

Cheers! Appreciate it.
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