Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; Use the following commands to throttle their
- ;; counterparts.
- ;; More can be added using the same format or
- ;; /throttle can be called directly using the
- ;; format of:
- ;; /throttle cmd [params]
- alias tmsg throttle msg $1-
- alias tdescribe throttle describe $1-
- alias tnotice throttle notice $1-
- ;; Workhorse; handles queueing and execution
- ;; throttled commanded
- alias throttle {
- ;; Throttle id - used for connection-specified
- ;; window and timer names
- var %TID = $+(@Throttle, $cid)
- ;; If not connected close the throttle buffer
- ;; window
- if ($status !== connected) {
- close -@ %TID
- }
- ;; If the input is not meant as a throttle
- ;; execution iteration
- elseif ($1- !=== -r) {
- ;; if the throttle buffer window is not open,
- ;; create it as a hidden & minimized list
- ;; window
- if (!$window(%TID)) {
- window -lnh0 %TID
- }
- ;; If the throttle-read timer is running,
- ;; simply add the input command to the
- ;; throttle buffer
- if ($timer(%TID)) {
- aline %TID $1-
- }
- ;; Otherwise, its been longer than 2 seconds
- ;; since a command has executed so execute
- ;; the input command and start the timer to
- ;; read the throttle buffer in 2 seconds
- else {
- $1-
- $+(.timer,%TID) 1 2 throttle -r
- }
- }
- ;; if the input is meant as a throttle read and
- ;; there is a throttled command to be executed,
- ;; execute the command, remove it from the
- ;; throttle buffer and start a timer to read
- ;; from the buffer again in 2 seconds
- elseif ($line(%TID, 1)) {
- $v1
- dline %TID 1
- $+(.timer, %TID) 1 2 throttle -r
- }
- }
- ;; When an outbound message is sent reset the
- ;; throttle-read timer. This is done so non
- ;; throttle commands reset the read-delay of
- ;; throttled commands
- on *:PARSELINE:out:*:{
- var %tid = $+(@Throttle, $cid)
- if ($timer(%tid)) {
- $+(.timer, %tid) 1 2 throttle -r
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement