Project

General

Profile

Actions

Added in 1.9.0

/timers [off]
/timer[n|name] [off]
/timer[n|name] [-cdehimopr] [time] <repetitions> <interval> <code>

Creates a timer that runs <code> at an interval.

If you are connected to server when the timer is started, it defaults to being a online timer, otherwise it will be a offline timer.

An offline timer will continue to run even if the server is disconnected, while a online timer will stop the timer when disconnected.

$identifiers and %vars in the <code> are evaluated at the creation time of the timer, to evaluate during the timer tick, the $ and % must be combined like this $ $+ identifier, % $+ varname.

Switches

Switch Description
-c Creates a catch-up timer.
-d TODO
-e Execute the code associated with a timer.
-h Create a high-resolution timer.
-i Dynamically associates itself with the active connection.
-m Treat the interval parameter as milliseconds instead of seconds.
-o Create a offline timer.
-p Pauses execution of the command. The timer continues counting down.
-P Pauses execution of the command and the countdown.
-r Resume a timer.

Parameters

Parameter Description
[off] Turns off a timer.
[n|name] The name or index of the timer.
[time] Executes the timer at the specified time in HH:MM (24 hour) format.
<repetitions> The number of times the timers should repeat itself. An repetition value of '0' will repeat forever. (or until DISCONNECT if it's an online timer)
<interval> The delay between two consecutive timer executions
<code> Code to be executed.

Example

alias example {
  ; Create a variable and set value to 5.
  var %reps = 5

  ; Call the timer %reps times after 1 second delay.
  .timer %reps 1 countdown 

  ; Print the first count.
  count-down
}

alias -l countdown {
  echo -ag Count: $timer($ltimer).reps
}

; Simple timer that sends a reply after 10 seconds.
on *:TEXT:hi:#adiirc:{ timer 1 10 msg $chan Hello, $nick $+ ! }

//timer 1 10 echo time of execution is $!asctime and time of launch is $asctime

/timerMidnite 00:00 1 0 echo -a it is now midnight!

Force it to execute now: /timerMidnite -e

WARNING Do NOT place strings into the command line of a timer which someone else can control. All strings beginning with % or $ (or if they follow comma or '#') could potentially be executed.

on *:FILERCVD:*.*:{ timer 1 0 msg #channel I received $nopath($filename) from $nick ! }

By placing this in a timer, someone can send you a filename containing the word %password to find out the value of that variable, or can force you to execute identifiers you don't wish to use, or could even be harmful to you.

One solution can be to keep messages in a @Queue window, or change the above to use $unsafe( $nopath($filename) ) instead.

Updated by Per Amundsen over 1 year ago · 17 revisions

Also available in: PDF HTML TXT