-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathschedule.csx
More file actions
34 lines (29 loc) · 1.31 KB
/
Copy pathschedule.csx
File metadata and controls
34 lines (29 loc) · 1.31 KB
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
29
30
31
32
33
34
#load "libs.csx"
public class ChatCommand : IChatCommand
{
public override AccountStateType AccountState => AccountStateType.User;
public override string CommandName => "schedule";
public override string HelpText => "usage: `/schedule` - Print details about the current scheduled tasks";
public override void Execute(DdonGameServer server, string[] command, GameClient client, ChatMessage message, List<ChatResponse> responses)
{
var lines = new List<string>();
lines.Add("# Task Cadence, Task Type, Next Update");
foreach (var task in server.ScheduleManager.GetTasks())
{
if (!task.IsEnabled(server) || task.Interval == ScheduleInterval.Secondly)
{
continue;
}
TimeSpan ts = TimeSpan.FromSeconds(server.ScheduleManager.TimeToNextTaskUpdate(task.Type));
var formattedTime = string.Format("{0:D1}d:{1:D2}h:{2:D2}m:{3:D2}s", ts.Days, ts.Hours, ts.Minutes, ts.Seconds);
var line = $"{task.TaskTypeName()}: {task.TaskName()} ({(uint)task.Type})\n {formattedTime}";
lines.Add(line);
}
foreach (var line in lines)
{
// Console.WriteLine(line);
responses.Add(ChatResponse.ServerChat(client, line));
}
}
}
return new ChatCommand();