Project

General

Profile

Timer » History » Version 17

Per Amundsen, 02/16/2023 03:32 PM

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