Renamed the bot from KickBot -> ChatBot and removed the reference to Kick in the project name

This commit is contained in:
barelyprofessional
2024-07-26 16:50:39 +08:00
parent f4db00246a
commit f9d87220d2
46 changed files with 84 additions and 84 deletions

View File

@@ -0,0 +1,30 @@
using System.Text.RegularExpressions;
using KfChatDotNetBot.Models.DbModels;
using KfChatDotNetWsClient.Models.Events;
using Microsoft.EntityFrameworkCore;
namespace KfChatDotNetBot.Commands;
public class WhoisCommand : ICommand
{
public List<Regex> Patterns => [
new Regex("^whois (?<user>.+)")
];
public string HelpText => "Lookup user IDs by username";
public bool HideFromHelp => false;
public UserRight RequiredRight => UserRight.Guest;
public async Task RunCommand(ChatBot botInstance, MessageModel message, GroupCollection arguments, CancellationToken ctx)
{
await using var db = new ApplicationDbContext();
var query = arguments["user"].Value.TrimStart('@').TrimEnd(',').TrimEnd();
var user = await db.Users.FirstOrDefaultAsync(u => u.KfUsername == query, cancellationToken: ctx);
if (user == null)
{
botInstance.SendChatMessage($"Requested user '{query}' does not exist. (Note this is case-sensitive)", true);
return;
}
botInstance.SendChatMessage($"@{message.Author.Username}, {user.KfUsername}'s ID is {user.KfId}", true);
}
}