mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
[whois] Add chatmember status to output. Update .gitignore.
This commit is contained in:
@@ -12,6 +12,7 @@ using Kruzya.TelegramBot.Core.Service;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
|
||||
namespace West.TelegramBot.ChatManagement.Handler
|
||||
{
|
||||
@@ -58,6 +59,7 @@ namespace West.TelegramBot.ChatManagement.Handler
|
||||
}
|
||||
else
|
||||
{
|
||||
message += $"<code>{await GetChatMemberStatusString(user)}</code>\n";
|
||||
message += $"<code>Репутация: {await GetUserReputation(user)}\n";
|
||||
message += $"Предупреждения: {(await GetWarnOption(user)).GetValue<int>()}</code>";
|
||||
}
|
||||
@@ -156,5 +158,24 @@ namespace West.TelegramBot.ChatManagement.Handler
|
||||
{
|
||||
return await Db.UserValues.FindOrCreateOption(Chat.Id, user.Id, "reputation");
|
||||
}
|
||||
|
||||
private async Task<string> GetChatMemberStatusString(User user)
|
||||
{
|
||||
var chatMember = await Bot.GetChatMemberAsync(Chat.Id, user.Id);
|
||||
var customStatus = _userService.GetUserCustomStatus(user.Id);
|
||||
if (customStatus != null)
|
||||
{
|
||||
return customStatus;
|
||||
}
|
||||
|
||||
|
||||
return chatMember.Status switch
|
||||
{
|
||||
ChatMemberStatus.Creator => "Владелец",
|
||||
ChatMemberStatus.Restricted => "Заблокированный",
|
||||
ChatMemberStatus.Administrator => "Администратор",
|
||||
_ => "Пользователь"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user