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.

Throttling

Help for those learning Tcl or writing their own scripts.
Post Reply
p
padyo
Voice
Posts: 4
Joined: Wed Jun 25, 2008 11:39 am

Throttling

Post by padyo »

I've read may of the topics concerning throttling

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
   }
}
  
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: Select all

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 :)
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

Just add it to this proc

Code: Select all

proc pDailySchedule {dayname nick uhost hand chan text} {
    if {[file exists ${dayname}.txt]} { 
like so

Code: Select all

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]} { 
:)
p
padyo
Voice
Posts: 4
Joined: Wed Jun 25, 2008 11:39 am

Post by padyo »

Cheers! Appreciate it.
Post Reply