mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 12:32:03 -04:00
Added a feature to shill the kasino almanac
This commit is contained in:
@@ -325,4 +325,95 @@ public class UnignoreCommand : ICommand
|
||||
await db.SaveChangesAsync(ctx);
|
||||
await botInstance.SendChatMessageAsync($"No longer ignoring {targetUser.KfUsername}", true);
|
||||
}
|
||||
}
|
||||
|
||||
public class SetAlmanacTextCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns => [
|
||||
new Regex("^admin almanac set text (?<text>.+)$")
|
||||
];
|
||||
|
||||
public string? HelpText => "Set the almanac text to whatever";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
await Helpers.SetValue(BuiltIn.Keys.BotAlmanacText, arguments["text"].Value);
|
||||
await botInstance.SendChatMessageAsync($"@{message.Author.Username}, updated text for the almanac shill", true);
|
||||
}
|
||||
}
|
||||
|
||||
public class SetAlmanacIntervalCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns => [
|
||||
new Regex("^admin almanac set interval (?<interval>.+)$")
|
||||
];
|
||||
|
||||
public string? HelpText => "Set the almanac interval to whatever in seconds";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
var interval = Convert.ToInt32(arguments["interval"].Value);
|
||||
if (interval < 300)
|
||||
{
|
||||
await botInstance.SendChatMessageAsync("Not going to let you use an interval below 300 seconds", true);
|
||||
return;
|
||||
}
|
||||
await Helpers.SetValue(BuiltIn.Keys.BotAlmanacInterval, arguments["interval"].Value);
|
||||
await botInstance.BotServices.AlmanacShill.StopShillTaskAsync();
|
||||
botInstance.BotServices.AlmanacShill.StartShillTask();
|
||||
await botInstance.SendChatMessageAsync($"@{message.Author.Username}, updated interval and restarted the shill task", true);
|
||||
}
|
||||
}
|
||||
public class StopAlmanacCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns => [
|
||||
new Regex("^admin almanac stop$")
|
||||
];
|
||||
|
||||
public string? HelpText => "Stop the almanac reminder";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
if (!botInstance.BotServices.AlmanacShill.IsShillTaskRunning())
|
||||
{
|
||||
await botInstance.SendChatMessageAsync("Looks like the task isn't even running", true);
|
||||
return;
|
||||
}
|
||||
|
||||
await botInstance.BotServices.AlmanacShill.StopShillTaskAsync();
|
||||
await botInstance.SendChatMessageAsync("Asked it nicely to stop", true);
|
||||
}
|
||||
}
|
||||
|
||||
public class StartAlmanacCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns => [
|
||||
new Regex("^admin almanac start")
|
||||
];
|
||||
|
||||
public string? HelpText => "Start the almanac reminder";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
if (botInstance.BotServices.AlmanacShill.IsShillTaskRunning())
|
||||
{
|
||||
await botInstance.SendChatMessageAsync("Looks like the task is already running", true);
|
||||
return;
|
||||
}
|
||||
|
||||
botInstance.BotServices.AlmanacShill.StartShillTask();
|
||||
await botInstance.SendChatMessageAsync("Asked it nicely to start", true);
|
||||
}
|
||||
}
|
||||
@@ -239,4 +239,24 @@ public class LastStreamCommand : ICommand
|
||||
var username = await Helpers.GetValue(BuiltIn.Keys.TwitchBossmanJackUsername);
|
||||
await botInstance.SendChatMessageAsync($"{username.Value} last streamed on Twitch approximately {timespan.Humanize(precision: 2, minUnit: TimeUnit.Minute, maxUnit: TimeUnit.Hour)} ago at {agt:dddd h:mm tt} AGT", true);
|
||||
}
|
||||
}
|
||||
|
||||
public class AlmanacCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns => [
|
||||
new Regex("^almanac", RegexOptions.IgnoreCase)
|
||||
];
|
||||
public string? HelpText => "Return details on how to submit almanac entries";
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var text = await Helpers.GetValue(BuiltIn.Keys.BotAlmanacText);
|
||||
if (message.MessageRaw.Contains("almanac plain"))
|
||||
{
|
||||
await botInstance.SendChatMessageAsync($"@{user.KfUsername}, [plain]{text.Value}", true);
|
||||
return;
|
||||
}
|
||||
await botInstance.SendChatMessageAsync($"@{user.KfUsername}, {text.Value}", true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user