Timer » History » Version 15
Per Amundsen, 12/14/2019 10:05 AM
| 1 | 1 | Per Amundsen | _Added in 1.9.0_ |
|---|---|---|---|
| 2 | |||
| 3 | */timers [off]* |
||
| 4 | */timer[n|name] [off]* |
||
| 5 | */timer[n|name] [-cdehimopr] [time] <repetitions> <interval> <code>* |
||
| 6 | |||
| 7 | 2 | Per Amundsen | Creates a timer that runs <code> at an interval. |
| 8 | |||
| 9 | 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. |
||
| 10 | |||
| 11 | 13 | Paul Janson | An offline timer will continue to run even if the server is disconnected, while a online timer will stop the timer when disconnected. |
| 12 | 2 | Per Amundsen | |
| 13 | 10 | Per Amundsen | _$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._ |
| 14 | 8 | Per Amundsen | |
| 15 | 1 | Per Amundsen | *Switches* |
| 16 | |||
| 17 | 14 | Per Amundsen | -c - Creates a catch-up timer. |
| 18 | 15 | Per Amundsen | -d - *TODO* |
| 19 | 6 | Per Amundsen | -e - Execute the code associated with a timer. |
| 20 | -h - Create a high-resolution timer. |
||
| 21 | 1 | Per Amundsen | -i - Dynamically associates itself with the active connection. |
| 22 | 6 | Per Amundsen | -m - Treat the interval parameter as milliseconds instead of seconds. |
| 23 | -o - Create a offline timer. |
||
| 24 | 14 | Per Amundsen | -p - Pauses execution of the command. The timer continues counting down. |
| 25 | -P - Pauses execution of the command and the countdown. |
||
| 26 | 6 | Per Amundsen | -r - Resume a timer. |
| 27 | 1 | Per Amundsen | |
| 28 | *Parameters* |
||
| 29 | |||
| 30 | 13 | Paul Janson | [off] - Turns off a timer. |
| 31 | 1 | Per Amundsen | [n|name] - The name or index of the timer. |
| 32 | 7 | Per Amundsen | [time] - Executes the timer at the specified time in HH:MM (24 hour) format. |
| 33 | 13 | Paul Janson | <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) |
| 34 | 1 | Per Amundsen | <interval> - The delay between two consecutive timer executions |
| 35 | <code> - Code to be executed. |
||
| 36 | |||
| 37 | *Example* |
||
| 38 | |||
| 39 | <pre> |
||
| 40 | alias example { |
||
| 41 | 4 | Per Amundsen | ; Create a variable and set value to 5. |
| 42 | var %reps = 5 |
||
| 43 | 1 | Per Amundsen | |
| 44 | 5 | Per Amundsen | ; Call the timer %reps times after 1 second delay. |
| 45 | 4 | Per Amundsen | .timer %reps 1 countdown |
| 46 | 1 | Per Amundsen | |
| 47 | 4 | Per Amundsen | ; Print the first count. |
| 48 | 1 | Per Amundsen | count-down |
| 49 | } |
||
| 50 | 4 | Per Amundsen | |
| 51 | alias -l countdown { |
||
| 52 | echo -ag Count: $timer($ltimer).reps |
||
| 53 | 1 | Per Amundsen | } |
| 54 | 11 | Per Amundsen | |
| 55 | 1 | Per Amundsen | ; Simple timer that sends a reply after 10 seconds. |
| 56 | on *:TEXT:hi:#freenode:{ timer 1 10 msg $chan Hello, $nick $+ ! } |
||
| 57 | </pre> |
||
| 58 | 13 | Paul Janson | |
| 59 | |||
| 60 | <pre> |
||
| 61 | |||
| 62 | //timer 1 10 echo time of execution is $!asctime and time of launch is $asctime |
||
| 63 | |||
| 64 | /timerMidnite 00:00 1 0 echo -a it is now midnight! |
||
| 65 | |||
| 66 | Force it to execute now: /timerMidnite -e |
||
| 67 | </pre> |
||
| 68 | |||
| 69 | *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. |
||
| 70 | |||
| 71 | <pre>on *:FILERCVD:*.*:{ timer 1 0 msg #channel I received $nopath($filename) from $nick ! }</pre> |
||
| 72 | |||
| 73 | 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. |
||
| 74 | |||
| 75 | One solution can be to keep messages in a @Queue window, or change the above to use $unsafe( $nopath($filename) ) instead. |