Whois command. Some refactorings.

This commit is contained in:
West14
2021-12-27 22:53:13 +02:00
parent 9bc08c58b7
commit b91d6cfdb5
6 changed files with 94 additions and 36 deletions
@@ -0,0 +1,32 @@
#nullable enable
using System.Threading.Tasks;
using BotFramework.Attributes;
using BotFramework.Enums;
using Kruzya.TelegramBot.Core.Data;
using Kruzya.TelegramBot.Core.Extensions;
namespace West.TelegramBot.ChatManagement.Handler
{
public class Reputation : ManagementHandler
{
public Reputation(CoreContext db) : base(db) {}
[Command("whois", CommandParseMode.Both)]
public async Task HandleWhois()
{
var user = RepliedUser ?? From;
var message = $"{user.ToHtml(false)}\n";
if (user.IsBot)
{
message += "<code>Бот</code>";
}
else
{
message += $"<code>Предупреждения: {(await GetWarnOption(user)).GetValue<int>()}</code>";
}
await Reply(message);
}
}
}