-
Notifications
You must be signed in to change notification settings - Fork 0
/
uptime.pike
28 lines (27 loc) · 1.09 KB
/
uptime.pike
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
inherit builtin_command;
constant builtin_description = "See if the channel is online, and if so, for how long";
constant builtin_name = "Channel uptime";
constant command_suggestions = (["!uptime": ([
"_description": "Show how long the channel has been online",
"builtin": "uptime",
"message": ([
"conditional": "string", "expr1": "{uptime}", "expr2": "0",
"message": "Channel is currently offline.",
"otherwise": "@$$: Channel {channel} has been online for {uptime|time_english}",
]),
])]);
constant vars_provided = ([
"{uptime}": "Number of seconds the channel has been online, or 0 if offline",
"{uptime_english}": "(deprecated) Equivalent to {uptime|time_english}",
"{uptime_hms}": "(deprecated) Equivalent to {uptime|time_hms}",
"{channel}": "Channel name (may later become the display name)",
]);
mapping message_params(object channel, mapping person, array params) {
int t = channel_uptime(channel->userid);
return ([
"{channel}": channel->config->display_name,
"{uptime}": (string)t,
"{uptime_english}": t ? describe_time(t) : "",
"{uptime_hms}": t ? describe_time_short(t) : "",
]);
}