mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 04:22:04 -04:00
Added rehab command
This commit is contained in:
@@ -179,4 +179,25 @@ public class CleanCommand : ICommand
|
||||
var timespan = DateTimeOffset.UtcNow - DateTimeOffset.Parse(start.Value);
|
||||
await botInstance.SendChatMessageAsync($"Bossman has been clean {timespan.Humanize(precision:5)}", true);
|
||||
}
|
||||
}
|
||||
|
||||
public class RehbCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns => [
|
||||
new Regex("^rehab")
|
||||
];
|
||||
public string? HelpText => "How long until rehab is over?";
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var end = await Helpers.GetValue(BuiltIn.Keys.BotRehabEndTime);
|
||||
if (end.Value == null)
|
||||
{
|
||||
await botInstance.SendChatMessageAsync("Bossman's rehab end date was null", true);
|
||||
return;
|
||||
}
|
||||
var timespan = DateTimeOffset.Parse(end.Value) - DateTimeOffset.UtcNow;
|
||||
await botInstance.SendChatMessageAsync($"Bossman's rehab will be over in roughly {timespan.Humanize(precision:3)}", true);
|
||||
}
|
||||
}
|
||||
@@ -580,6 +580,15 @@ public static class BuiltIn
|
||||
Default = "2024-09-19T13:33:00-04:00",
|
||||
IsSecret = false,
|
||||
CacheDuration = TimeSpan.FromHours(1)
|
||||
},
|
||||
new BuiltInSettingsModel
|
||||
{
|
||||
Key = Keys.BotRehabEndTime,
|
||||
Regex = ".+",
|
||||
Description = "ISO8601 date of Bossman's rehab end",
|
||||
Default = "2024-10-24T09:00:00-04:00",
|
||||
IsSecret = false,
|
||||
CacheDuration = TimeSpan.FromHours(1)
|
||||
}
|
||||
];
|
||||
|
||||
@@ -636,5 +645,6 @@ public static class BuiltIn
|
||||
public static string BotPraygeImgUrl = "Bot.Prayge.ImgUrl";
|
||||
public static string BotCrackpipeImgUrl = "Bot.Crackpipe.ImgUrl";
|
||||
public static string BotCleanStartTime = "Bot.Clean.StartTime";
|
||||
public static string BotRehabEndTime = "Bot.Rehab.EndTime";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user