|
@@ -0,0 +1,40 @@
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using MafiaTelegramBot.Controllers;
|
|
|
+using MafiaTelegramBot.DataBase.EntityDao;
|
|
|
+using MafiaTelegramBot.Extensions;
|
|
|
+using MafiaTelegramBot.Game;
|
|
|
+using MafiaTelegramBot.Resources;
|
|
|
+using Telegram.Bot.Types;
|
|
|
+
|
|
|
+namespace MafiaTelegramBot.Commands.Messages
|
|
|
+{
|
|
|
+ public class UnblockUserMessageHandler : UpdateHandler
|
|
|
+ {
|
|
|
+ protected override string Command => "";
|
|
|
+
|
|
|
+ private static readonly List<long> Queue = new();
|
|
|
+
|
|
|
+ public static void AddToQueue(long id)
|
|
|
+ {
|
|
|
+ Queue.AddUnique(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ public override bool IsMatches(string command)
|
|
|
+ {
|
|
|
+ return User != null ? Queue.Contains(User.Info.Id) : base.IsMatches(command);
|
|
|
+ }
|
|
|
+
|
|
|
+ public override async Task<Message> Execute(Update update)
|
|
|
+ {
|
|
|
+ Queue.Remove(User.Info.Id);
|
|
|
+ var targetId = await UserDao.GetIdByUsername(update.Message.Text);
|
|
|
+ if (targetId == -1) return await MessageController.SendText(User.Info, strings.user_not_exists);
|
|
|
+ var target = await UserDao.GetPlayerById(targetId);
|
|
|
+ target.Info.IsBlocked = false;
|
|
|
+ return await MessageController.SendText(User.Info, $"{strings.successfully_unblock_user} {target.Info.NickName}");
|
|
|
+ }
|
|
|
+
|
|
|
+ public UnblockUserMessageHandler(Player player) : base(player) { }
|
|
|
+ }
|
|
|
+}
|