Browse Source

Big Refactor Code

Tigran 4 năm trước cách đây
mục cha
commit
f32983636c
42 tập tin đã thay đổi với 811 bổ sung622 xóa
  1. 3 1
      MafiaTelegramBot.sln.DotSettings.user
  2. 5 5
      MafiaTelegramBot/Controllers/RoomController.cs
  3. 13 5
      MafiaTelegramBot/DataBase/User.cs
  4. 1 1
      MafiaTelegramBot/DataBase/UserDao.cs
  5. 1 1
      MafiaTelegramBot/Game/GameRoom.cs
  6. 18 0
      MafiaTelegramBot/MafiaTelegramBot.csproj
  7. 3 14
      MafiaTelegramBot/Models/Bot.cs
  8. 23 2
      MafiaTelegramBot/Models/Commands/Command.cs
  9. 4 3
      MafiaTelegramBot/Models/Commands/ConnectGameCommand.cs
  10. 4 3
      MafiaTelegramBot/Models/Commands/CreateGameCommand.cs
  11. 20 0
      MafiaTelegramBot/Models/Commands/CustomMessageHandlers/ChangeNicknameCommand.cs
  12. 39 0
      MafiaTelegramBot/Models/Commands/CustomMessageHandlers/CreateRoomCommand.cs
  13. 42 0
      MafiaTelegramBot/Models/Commands/CustomMessageHandlers/EnterPrivateRoomCommand.cs
  14. 0 108
      MafiaTelegramBot/Models/Commands/CustomMessageHandlingCommand.cs
  15. 2 14
      MafiaTelegramBot/Models/Commands/LeaveCommand.cs
  16. 30 0
      MafiaTelegramBot/Models/Commands/LookPlayersListCommand.cs
  17. 4 2
      MafiaTelegramBot/Models/Commands/RoomSettingsCommand.cs
  18. 6 5
      MafiaTelegramBot/Models/Commands/ShowProfileCommand.cs
  19. 33 54
      MafiaTelegramBot/Models/Commands/StartCommand.cs
  20. 2 1
      MafiaTelegramBot/Models/Inlines/ChangeNameQuery.cs
  21. 1 3
      MafiaTelegramBot/Models/Inlines/ConnectToPrivateRoomQuery.cs
  22. 13 19
      MafiaTelegramBot/Models/Inlines/ConnectToPublicRoomQuery.cs
  23. 8 17
      MafiaTelegramBot/Models/Inlines/ConnectToSelectedRoomQuery.cs
  24. 3 2
      MafiaTelegramBot/Models/Inlines/DecreaseRoomMaxCapacity.cs
  25. 3 2
      MafiaTelegramBot/Models/Inlines/IncreaseRoomMaxCapacityQuery.cs
  26. 0 41
      MafiaTelegramBot/Models/Inlines/LookUsersListQuery.cs
  27. 2 1
      MafiaTelegramBot/Models/Inlines/MakeExtendedGameQuery.cs
  28. 4 3
      MafiaTelegramBot/Models/Inlines/MakePrivateRoomQuery.cs
  29. 4 3
      MafiaTelegramBot/Models/Inlines/MakePublicRoomQuery.cs
  30. 2 1
      MafiaTelegramBot/Models/Inlines/MakeStandartGameQuery.cs
  31. 3 2
      MafiaTelegramBot/Models/Inlines/MyRolesQuery.cs
  32. 4 3
      MafiaTelegramBot/Models/Inlines/SettingsQuery.cs
  33. 2 1
      MafiaTelegramBot/Models/Inlines/SettingsRoomQuery.cs
  34. 3 2
      MafiaTelegramBot/Models/Inlines/ShopQuery.cs
  35. 29 0
      MafiaTelegramBot/Resources/Keyboards.cs
  36. 189 0
      MafiaTelegramBot/Resources/callback.Designer.cs
  37. 63 0
      MafiaTelegramBot/Resources/callback.resx
  38. 135 0
      MafiaTelegramBot/Resources/keyboard.Designer.cs
  39. 45 0
      MafiaTelegramBot/Resources/keyboard.resx
  40. 20 227
      MafiaTelegramBot/Resources/strings.Designer.cs
  41. 7 76
      MafiaTelegramBot/Resources/strings.resx
  42. 18 0
      MafiaTelegramBot/Utilities.cs

+ 3 - 1
MafiaTelegramBot.sln.DotSettings.user

@@ -1,6 +1,8 @@
 <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
 	<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=MafiaTelegramBot_002Fappsettings/@EntryIndexedValue">True</s:Boolean>
-	<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=MafiaTelegramBot_002FResources_002Fstrings/@EntryIndexedValue">True</s:Boolean>
+	<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=MafiaTelegramBot_002FResources_002Fcallback/@EntryIndexedValue">False</s:Boolean>
+	<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=MafiaTelegramBot_002FResources_002Fkeyboard/@EntryIndexedValue">True</s:Boolean>
+	<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=MafiaTelegramBot_002FResources_002Fstrings/@EntryIndexedValue">False</s:Boolean>
 	<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=MafiaTelegramBot_002Fstrings/@EntryIndexedValue">True</s:Boolean>
 	
 	<s:Boolean x:Key="/Default/ResxEditorPersonal/Initialized/@EntryValue">True</s:Boolean>

+ 5 - 5
MafiaTelegramBot/Controllers/RoomController.cs

@@ -22,7 +22,7 @@ namespace MafiaTelegramBot.Controllers
                     ? new GameRoom {Creator = owner, RoomName = roomName, IsExtended = extended}
                     : new PrivateGameRoom {Creator = owner, RoomName = roomName, IsExtended = extended};
                 OpenedGames.Add(secretPhrase ?? roomName, room);
-                room.Players.Add(owner.Username, owner);
+                room.Players.Add(owner.Id, owner);
                 return ResultCode.CodeOk;
             });
         }
@@ -31,10 +31,10 @@ namespace MafiaTelegramBot.Controllers
         {
             return await Task.Run(async () =>
             {
+                if (!OpenedGames.ContainsKey(roomKey)) return ResultCode.RoomDoesNotExist;
                 if (OpenedGames[roomKey].IsFilled()) return ResultCode.RoomIsFilled;
-                if (OpenedGames.ContainsKey(roomKey)) return ResultCode.RoomIsFilled;
-                if (! await player.SetRoomKey(OpenedGames[roomKey].RoomName)) return ResultCode.UserAlreadyInGame;
-                OpenedGames[roomKey].Players.Add(player.Username, player);
+                if (!await player.SetRoomKey(roomKey)) return ResultCode.UserAlreadyInGame;
+                OpenedGames[roomKey].Players.Add(player.Id, player);
                 return ResultCode.CodeOk;
             });
         }
@@ -55,7 +55,7 @@ namespace MafiaTelegramBot.Controllers
             {
                 var roomKey = player.GetRoomKey();
                 if (!await player.RemoveGame()) return ResultCode.UserNotInGame;
-                OpenedGames[roomKey].Players.Remove(player.Username);
+                OpenedGames[roomKey].Players.Remove(player.Id);
                 if (OpenedGames[roomKey].Players.Count == 0) OpenedGames.Remove(roomKey);
                 return ResultCode.CodeOk;
             });

+ 13 - 5
MafiaTelegramBot/DataBase/User.cs

@@ -9,21 +9,19 @@ namespace MafiaTelegramBot.DataBase
     {
         public long Id { get; init; }
         public long ChatId { get; init; }
-        public string Username { get; set; } = strings.no_name;
+        public string Username { get; init; } = strings.no_name;
         public int Games { get; set; } = 0;
+        public string NickName { get; set; } = "";
         public int Wins { get; set; } = 0;
         public Dictionary<string, int> RoleGames = new();
         public Dictionary<string, int> RoleWins = new();
 
         private string _roomKey = "";
         
-        public string FirstName { get; init; } = "";
-        
-        public string LastName { get; init; } = "";
 
         public async Task UpdateName(string name)
         {
-            Username = name;
+            NickName = name;
             await UserDao.Update(this);
         }
 
@@ -57,5 +55,15 @@ namespace MafiaTelegramBot.DataBase
             await UserDao.Update(this);
             return true;
         }
+
+        public override bool Equals(object? obj)
+        {
+            return obj is User user && user.Id == Id;
+        }
+
+        public override int GetHashCode()
+        {
+            return Id.GetHashCode();
+        }
     }
 }

+ 1 - 1
MafiaTelegramBot/DataBase/UserDao.cs

@@ -32,7 +32,7 @@ namespace MafiaTelegramBot.DataBase
         {
             return await Task.Run(() =>
             {
-                return DataBase.Exists(user => user.Id == id);
+                return ActiveUsers.ContainsKey(id) || DataBase.Exists(user => user.Id == id);
             });
         }
     }

+ 1 - 1
MafiaTelegramBot/Game/GameRoom.cs

@@ -15,7 +15,7 @@ namespace MafiaTelegramBot.Game
         public bool IsExtended { get; init; } = false;
         public string RoomName { get; init; } = "NoNameRoom";
         public User Creator { get; init; } = new();
-        public readonly Dictionary<string, User> Players = new();
+        public readonly Dictionary<long, User> Players = new();
         public readonly Dictionary<string, string> Settings = new();
 
         public async Task<ResultCode> Start()

+ 18 - 0
MafiaTelegramBot/MafiaTelegramBot.csproj

@@ -17,6 +17,14 @@
         <Generator>ResXFileCodeGenerator</Generator>
         <LastGenOutput>strings.Designer.cs</LastGenOutput>
       </EmbeddedResource>
+      <EmbeddedResource Update="Resources\keyboard.resx">
+        <Generator>ResXFileCodeGenerator</Generator>
+        <LastGenOutput>keyboard.Designer.cs</LastGenOutput>
+      </EmbeddedResource>
+      <EmbeddedResource Update="Resources\callback.resx">
+        <Generator>ResXFileCodeGenerator</Generator>
+        <LastGenOutput>callback.Designer.cs</LastGenOutput>
+      </EmbeddedResource>
     </ItemGroup>
 
     <ItemGroup>
@@ -25,6 +33,16 @@
         <AutoGen>True</AutoGen>
         <DependentUpon>strings.resx</DependentUpon>
       </Compile>
+      <Compile Update="Resources\keyboard.Designer.cs">
+        <DesignTime>True</DesignTime>
+        <AutoGen>True</AutoGen>
+        <DependentUpon>keyboard.resx</DependentUpon>
+      </Compile>
+      <Compile Update="Resources\callback.Designer.cs">
+        <DesignTime>True</DesignTime>
+        <AutoGen>True</AutoGen>
+        <DependentUpon>callback.resx</DependentUpon>
+      </Compile>
     </ItemGroup>
 
 </Project>

+ 3 - 14
MafiaTelegramBot/Models/Bot.cs

@@ -52,9 +52,7 @@ namespace MafiaTelegramBot.Models
                 new ShowProfileCommand(),
                 new RoomSettingsCommand(),
                 new LeaveCommand(),
-                
-                //it always in end of array, handle all messages, that doesn't contains command string
-                new CustomMessageHandlingCommand()
+                new LookPlayersListCommand(),
             };
         }
         
@@ -74,7 +72,6 @@ namespace MafiaTelegramBot.Models
                 new ChangeNameQuery(),
                 new SettingsRoomQuery(),
                 new ConnectToPrivateRoomQuery(),
-                new LookUsersListQuery(),
                 new IncreaseRoomMaxCapacityQuery(),
                 new DecreaseRoomMaxCapacity(),
                 new ConnectToPublicRoomQuery(),
@@ -93,16 +90,8 @@ namespace MafiaTelegramBot.Models
         
         public static async Task<Message> SendWithMarkdown2(long chatId, string message, IReplyMarkup replyMarkup = null)
         {
-            var newMessage = await Task.Run(()=> message
-                .Replace(".", "\\.")
-                .Replace("@", "\\@")
-                .Replace("#", "\\#")
-                .Replace("!", "\\!")
-                .Replace("-", "\\-")
-            );
-            return replyMarkup == null
-                ? await Get().SendTextMessageAsync(chatId, newMessage, ParseMode.MarkdownV2)
-                : await Get().SendTextMessageAsync(chatId, newMessage, ParseMode.MarkdownV2, replyMarkup: replyMarkup);
+            return await Get().SendTextMessageAsync(chatId, await Utilities.ToMarkdownString(message),
+                ParseMode.MarkdownV2, replyMarkup: replyMarkup);
         }
     }
 }

+ 23 - 2
MafiaTelegramBot/Models/Commands/Command.cs

@@ -1,15 +1,36 @@
+using System.Collections.Generic;
 using System.Threading.Tasks;
+using MafiaTelegramBot.Models.Commands.CustomMessageHandlers;
 using Telegram.Bot.Types;
+using Telegram.Bot.Types.Enums;
 
 namespace MafiaTelegramBot.Models.Commands
 {
     public abstract class Command : UpdateModel
     {
-        public static Task Update(Update update)
+        private static Dictionary<string, Command> _customHandlers = new()
         {
+            {"UsersThatChangesNickname", new ChangeNicknameCommand()},
+            {"UsersThatCreatesRoom", new CreateRoomCommand()},
+            {"UserThatEntersPrivateCode", new EnterPrivateRoomCommand()},
+        };
+        public static async Task<Message> Update(Update update)
+        {
+            var chatId = update.Message.Chat.Id;
+            await Bot.Get().SendChatActionAsync(chatId, ChatAction.Typing);
             var commands = Bot.Commands;
             var message = update.Message.Text;
-            return FirstOrDefault(commands, message).Execute(update);
+            var command = FirstOrDefault(commands, message);
+            if (command != null) return await command.Execute(update);
+            var userId = update.Message.From.Id;
+            
+            if (Bot.UsersThatChangesNickname.Remove(userId))
+                return await _customHandlers["UsersThatChangesNickname"].Execute(update);
+            if (Bot.UsersThatCreatesRoom.ContainsKey(userId))
+                return await _customHandlers["UsersThatCreatesRoom"].Execute(update);
+            if (Bot.UserThatEntersPrivateCode.Remove(userId))
+                return await _customHandlers["UserThatEntersPrivateCode"].Execute(update);
+            return await Bot.SendWithMarkdown2(chatId, $"{strings.command_not_found} _*\\({message}\\)*_");
         }
     }
 }

+ 4 - 3
MafiaTelegramBot/Models/Commands/ConnectGameCommand.cs

@@ -1,5 +1,6 @@
 using System.Threading.Tasks;
 using MafiaTelegramBot.DataBase;
+using MafiaTelegramBot.Resources;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
 using Telegram.Bot.Types.ReplyMarkups;
@@ -8,7 +9,7 @@ namespace MafiaTelegramBot.Models.Commands
 {
     public class ConnectGameCommand : Command
     {
-        protected override string Name => strings.connect_game;
+        protected override string Name => keyboard.connect_game;
 
         public override async Task<Message> Execute(Update update)
         {
@@ -21,8 +22,8 @@ namespace MafiaTelegramBot.Models.Commands
                 return await Bot.SendWithMarkdown2(chatId, $"{strings.user_already_playing} _*{await user.GetRoomName()}*_");
             var inlineKeyboard = new InlineKeyboardMarkup(new[]
             {
-                new[] {InlineKeyboardButton.WithCallbackData(strings.connect_to_public_room, $"{strings.connect_to_public_room_callback}|{userId}")},
-                new[] {InlineKeyboardButton.WithCallbackData(strings.connect_to_private_room, $"{strings.connect_to_private_room_callback}|{userId}")}
+                new[] {InlineKeyboardButton.WithCallbackData(strings.connect_to_public_room, $"{callback.connect_to_public_room}|{userId}")},
+                new[] {InlineKeyboardButton.WithCallbackData(strings.connect_to_private_room, $"{callback.connect_to_private_room}|{userId}")}
             });
             return await Bot.SendWithMarkdown2(chatId, strings.choose_type_room, inlineKeyboard);
         }

+ 4 - 3
MafiaTelegramBot/Models/Commands/CreateGameCommand.cs

@@ -1,5 +1,6 @@
 using System.Threading.Tasks;
 using MafiaTelegramBot.DataBase;
+using MafiaTelegramBot.Resources;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
 using Telegram.Bot.Types.ReplyMarkups;
@@ -8,7 +9,7 @@ namespace MafiaTelegramBot.Models.Commands
 {
     public class CreateGameCommand : Command
     {
-        protected override string Name => strings.create_game;
+        protected override string Name => keyboard.create_game;
         public override async Task<Message> Execute(Update update)
         {
             var chatId = update.Message.Chat.Id;
@@ -19,8 +20,8 @@ namespace MafiaTelegramBot.Models.Commands
                 return await Bot.SendWithMarkdown2(chatId, $"{strings.user_already_playing} _*{await user.GetRoomName()}*_");
             var inlineKeyboard = new InlineKeyboardMarkup(new[]
             {
-                new[] {InlineKeyboardButton.WithCallbackData(strings.make_public_room, $"{strings.make_public_room_callback}|{userId}")},
-                new[] {InlineKeyboardButton.WithCallbackData(strings.make_private_room, $"{strings.make_private_room_callback}|{userId}")}
+                new[] {InlineKeyboardButton.WithCallbackData(strings.make_public_room, $"{callback.make_public_room}|{userId}")},
+                new[] {InlineKeyboardButton.WithCallbackData(strings.make_private_room, $"{callback.make_private_room}|{userId}")}
             });
             return await Bot.SendWithMarkdown2(chatId, strings.settings_room, inlineKeyboard);
         }

+ 20 - 0
MafiaTelegramBot/Models/Commands/CustomMessageHandlers/ChangeNicknameCommand.cs

@@ -0,0 +1,20 @@
+using System.Threading.Tasks;
+using MafiaTelegramBot.DataBase;
+using Telegram.Bot.Types;
+
+namespace MafiaTelegramBot.Models.Commands.CustomMessageHandlers
+{
+    public class ChangeNicknameCommand : Command
+    {
+        protected override string Name => "ChangeNicknameCommand";
+        public override async Task<Message> Execute(Update update)
+        {
+            var userId = update.Message.From.Id;
+            var chatId = update.Message.Chat.Id;
+            var newNickname = update.Message.Text;
+            var user = await UserDao.GetUserById(userId);
+            await user.UpdateName(newNickname);
+            return await Bot.SendWithMarkdown2(chatId, $"{strings.name_updated} _*{newNickname}*_");
+        }
+    }
+}

+ 39 - 0
MafiaTelegramBot/Models/Commands/CustomMessageHandlers/CreateRoomCommand.cs

@@ -0,0 +1,39 @@
+using System.Threading.Tasks;
+using MafiaTelegramBot.Controllers;
+using MafiaTelegramBot.DataBase;
+using MafiaTelegramBot.Game;
+using MafiaTelegramBot.Resources;
+using Telegram.Bot.Types;
+
+namespace MafiaTelegramBot.Models.Commands.CustomMessageHandlers
+{
+    public class CreateRoomCommand : Command
+    {
+        protected override string Name => "CreateRoomCommand";
+        public override async Task<Message> Execute(Update update)
+        {
+            var userId = update.Message.From.Id;
+            var chatId = update.Message.Chat.Id;
+            var param = Bot.UsersThatCreatesRoom[userId];
+            Bot.UsersThatCreatesRoom.Remove(userId);
+            var user = await UserDao.GetUserById(userId);
+            var roomName = update.Message.Text;
+            var resultCode = param[0] == "public"
+                ? await RoomController.CreateNewGame(user, roomName, param[1] == callback.extended)
+                : await RoomController.CreateNewGame(user, roomName, param[1] == callback.extended, RoomEncrypter.Encrypt(roomName));
+            var result = resultCode switch
+            {
+                ResultCode.CodeOk => await Bot.SendWithMarkdown2(chatId, $"{strings.room_with_name} _*{roomName}*_ {strings.was_created}", Keyboards.OwnerGameMenu),
+                ResultCode.UserAlreadyInGame => await Bot.SendWithMarkdown2(chatId, $"{strings.user_already_playing} _*{await user.GetRoomName()}*_"),
+                ResultCode.GameAlreadyExists => await Bot.SendWithMarkdown2(chatId, $"{strings.room} _*{roomName}*_ {strings.already_exists}"),
+                _ => await Bot.SendWithMarkdown2(chatId, strings.unexpected_error)
+            };
+            if (resultCode == ResultCode.CodeOk && param[0] == "private")
+            {
+                await Bot.SendWithMarkdown2(chatId,
+                    $"{strings.secret_key_is} _*{roomName}*_: ```{RoomEncrypter.NameToCode(roomName)}```");
+            }
+            return result;
+        }
+    }
+}

+ 42 - 0
MafiaTelegramBot/Models/Commands/CustomMessageHandlers/EnterPrivateRoomCommand.cs

@@ -0,0 +1,42 @@
+using System.Linq;
+using System.Threading.Tasks;
+using MafiaTelegramBot.Controllers;
+using MafiaTelegramBot.DataBase;
+using MafiaTelegramBot.Resources;
+using Telegram.Bot.Types;
+
+namespace MafiaTelegramBot.Models.Commands.CustomMessageHandlers
+{
+    public class EnterPrivateRoomCommand : Command
+    {
+        protected override string Name => "EnterPrivateRoomCommand";
+        public override async Task<Message> Execute(Update update)
+        {
+            var userId = update.Message.From.Id;
+            var chatId = update.Message.Chat.Id;
+            var user = await UserDao.GetUserById(userId);
+            var roomKey = update.Message.Text;
+            var resultCode = await RoomController.ConnectToGame(user, roomKey);
+            switch (resultCode)
+            {
+                case ResultCode.CodeOk:
+                {
+                    var users = await RoomController.GetPlayers(roomKey);
+                    foreach (var player in users.Where(player => userId != player.Id))
+                    {
+                        await Bot.SendWithMarkdown2(player.ChatId, $"{strings.entry_another_user} _*{user.NickName}*_");
+                    }
+                    return await Bot.SendWithMarkdown2(chatId, strings.successful_entry_into_room, Keyboards.PlayerGameMenu);
+                }
+                case ResultCode.RoomIsFilled:
+                    return await Bot.SendWithMarkdown2(chatId, strings.room_is_filled);
+                case ResultCode.UserAlreadyInGame:
+                    return await Bot.SendWithMarkdown2(chatId, strings.user_already_in_game);
+                case ResultCode.RoomDoesNotExist:
+                    return await Bot.SendWithMarkdown2(chatId, strings.room_does_not_exists);
+                default:
+                    return await Bot.SendWithMarkdown2(chatId, strings.unexpected_error);
+            }
+        }
+    }
+}

+ 0 - 108
MafiaTelegramBot/Models/Commands/CustomMessageHandlingCommand.cs

@@ -1,108 +0,0 @@
-using System.Linq;
-using System.Threading.Tasks;
-using MafiaTelegramBot.Controllers;
-using MafiaTelegramBot.DataBase;
-using MafiaTelegramBot.Game;
-using MafiaTelegramBot.Resources;
-using Telegram.Bot.Types;
-using Telegram.Bot.Types.Enums;
-using Telegram.Bot.Types.ReplyMarkups;
-
-namespace MafiaTelegramBot.Models.Commands
-{
-    public class CustomMessageHandlingCommand : Command
-    {
-        protected override string Name => "";
-        public override async Task<Message> Execute(Update update)
-        {
-            var chatId = update.Message.Chat.Id;
-            await Bot.Get().SendChatActionAsync(chatId, ChatAction.Typing);
-            var message = update.Message.Text;
-            var userId = update.Message.From.Id;
-            
-            if (Bot.UsersThatChangesNickname.Remove(userId))
-                return await ChangeNicknameLogic(userId, chatId, message);
-            if (Bot.UsersThatCreatesRoom.ContainsKey(userId))
-            {
-                var param = Bot.UsersThatCreatesRoom[userId];
-                Bot.UsersThatCreatesRoom.Remove(userId);
-                return await CreateRoomLogic(userId, chatId, message, param);
-            }
-
-            if (Bot.UserThatEntersPrivateCode.Remove(userId))
-            {
-                return await EnterPrivateCodeLogic(userId, chatId, message);
-            }
-            return await Bot.SendWithMarkdown2(chatId, $"{strings.command_not_found} _*\\({message}\\)*_");
-        }
-        
-        
-        private static async Task<Message> EnterPrivateCodeLogic(long userId, long chatId, string message)
-        {
-            var user = await UserDao.GetUserById(userId);
-            var resultCode = await RoomController.ConnectToGame(user, message);
-            switch (resultCode)
-            {
-                case ResultCode.CodeOk:
-                {
-                    var users = await RoomController.GetPlayers(message);
-                    foreach (var player in users.Where(player => userId != player.Id))
-                    {
-                        await Bot.SendWithMarkdown2(player.ChatId, $"{strings.entry_another_user} _*{user?.Username}*_");
-                    }
-                    var keyboard = new InlineKeyboardMarkup(new []
-                    {
-                        new []{
-                            InlineKeyboardButton.WithCallbackData(strings.look_user_list, $"{strings.look_user_list_callback}|{userId}|{message}"),
-                            InlineKeyboardButton.WithCallbackData(strings.leave, $"{strings.leave_callback}|{userId}")
-                        }
-                    });
-                    return await Bot.SendWithMarkdown2(chatId, strings.successful_entry_into_room, keyboard);
-                }
-                case ResultCode.RoomIsFilled:
-                    return await Bot.SendWithMarkdown2(chatId, strings.room_is_filled);
-                case ResultCode.UserAlreadyInGame:
-                    return await Bot.SendWithMarkdown2(chatId, strings.user_already_in_game);
-                default:
-                    return await Bot.SendWithMarkdown2(chatId, strings.unexpected_error);
-            }
-
-        }
-        
-        private static async Task<Message> ChangeNicknameLogic(long userId, long chatId, string message)
-        {
-            var user = await UserDao.GetUserById(userId);
-            await user!.UpdateName(message);
-            return await Bot.SendWithMarkdown2(chatId, $"{strings.name_updated} _*{message}*_");
-        }
-
-        private static async Task<Message> CreateRoomLogic(long userId, long chatId, string roomName, string[] param)
-        {
-            var user = await UserDao.GetUserById(userId);
-            var resultCode = param[0] == "public"
-                ? await RoomController.CreateNewGame(user, roomName, param[1] == strings.extended_callback)
-                : await RoomController.CreateNewGame(user, roomName, param[1] == strings.extended_callback, RoomEncrypter.Encrypt(roomName));
-            var keyboard = new ReplyKeyboardMarkup (
-                new[]
-                {
-                    new KeyboardButton[] {strings.begin_game, strings.settings_to_room},
-                    new KeyboardButton[] {strings.kick_player, strings.leave}
-                },
-                true
-            );
-            var result = resultCode switch
-            {
-                ResultCode.CodeOk => await Bot.SendWithMarkdown2(chatId, $"{strings.room_with_name} _*{roomName}*_ {strings.was_created}", keyboard),
-                ResultCode.UserAlreadyInGame => await Bot.SendWithMarkdown2(chatId, $"{strings.user_already_playing} _*{await user.GetRoomName()}*_"),
-                ResultCode.GameAlreadyExists => await Bot.SendWithMarkdown2(chatId, $"{strings.room} _*{roomName}*_ {strings.already_exists}"),
-                _ => await Bot.SendWithMarkdown2(chatId, strings.unexpected_error)
-            };
-            if (resultCode == ResultCode.CodeOk && param[0] == "private")
-            {
-                await Bot.SendWithMarkdown2(chatId,
-                    $"{strings.secret_key_is} _*{roomName}*_: ```{RoomEncrypter.NameToCode(roomName)}```");
-            }
-            return result;
-        }
-    }
-}

+ 2 - 14
MafiaTelegramBot/Models/Commands/LeaveCommand.cs

@@ -4,13 +4,12 @@ using MafiaTelegramBot.DataBase;
 using MafiaTelegramBot.Resources;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
-using Telegram.Bot.Types.ReplyMarkups;
 
 namespace MafiaTelegramBot.Models.Commands
 {
     public class LeaveCommand : Command
     {
-        protected override string Name => strings.leave;
+        protected override string Name => keyboard.leave;
         public override async Task<Message> Execute(Update update)
         {
             var chatId = update.Message.Chat.Id;
@@ -20,20 +19,9 @@ namespace MafiaTelegramBot.Models.Commands
             var user = await UserDao.GetUserById(userId);
             var roomName = await user.GetRoomName();
             var result = await RoomController.LeaveFromGame(user);
-            
-            ReplyKeyboardMarkup keyboard = new(
-                new[]
-                {
-                    new KeyboardButton[] {strings.create_game},
-                    new KeyboardButton[] {strings.connect_game},
-                    new KeyboardButton[] {strings.show_profile}
-                },
-                true
-            );
-            
             return result switch
             {
-                ResultCode.CodeOk => await Bot.SendWithMarkdown2(chatId, $"{strings.leave_from_game} _*{roomName}*_", keyboard),
+                ResultCode.CodeOk => await Bot.SendWithMarkdown2(chatId, $"{strings.leave_from_game} _*{roomName}*_", Keyboards.MainMenu),
                 ResultCode.UserNotInGame => await Bot.SendWithMarkdown2(chatId, strings.not_in_game),
                 _ => await Bot.SendWithMarkdown2(chatId, strings.unexpected_error)
             };

+ 30 - 0
MafiaTelegramBot/Models/Commands/LookPlayersListCommand.cs

@@ -0,0 +1,30 @@
+using System.Linq;
+using System.Threading.Tasks;
+using MafiaTelegramBot.Controllers;
+using MafiaTelegramBot.DataBase;
+using MafiaTelegramBot.Resources;
+using Telegram.Bot.Types;
+using Telegram.Bot.Types.Enums;
+
+namespace MafiaTelegramBot.Models.Commands
+{
+    public class LookPlayersListCommand : Command
+    {
+        protected override string Name => keyboard.look_players_list;
+        
+        public override async Task<Message> Execute(Update update)
+        {
+            var chatId = update.Message.Chat.Id;
+            await Bot.Get().SendChatActionAsync(chatId, ChatAction.Typing);
+            var userId = update.Message.From.Id;
+            var user = await UserDao.GetUserById(userId);
+            var roomKey = user.GetRoomKey();
+            var users = await RoomController.GetPlayers(roomKey);
+            var list = users.Count > 1
+                ? users.Where(player => !player.Equals(user))
+                    .Aggregate(strings.users_list, (current, player) => current + $"\n \n@{player.Username}\n{player.NickName}")
+                : strings.users_list_empty;
+            return await Bot.SendWithMarkdown2(chatId, list);
+        }
+    }
+}

+ 4 - 2
MafiaTelegramBot/Models/Commands/RoomSettingsCommand.cs

@@ -1,6 +1,7 @@
 using System.Threading.Tasks;
 using MafiaTelegramBot.Controllers;
 using MafiaTelegramBot.DataBase;
+using MafiaTelegramBot.Resources;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.ReplyMarkups;
 
@@ -8,7 +9,7 @@ namespace MafiaTelegramBot.Models.Commands
 {
     public class RoomSettingsCommand:Command
     {
-        protected override string Name => strings.settings_to_room;
+        protected override string Name => keyboard.room_settings;
         public override async Task<Message> Execute(Update update)
         {
             var chatId = update.Message.Chat.Id;
@@ -23,7 +24,8 @@ namespace MafiaTelegramBot.Models.Commands
             
             var inlineKeyboard = new InlineKeyboardMarkup(new[]
             {
-                new[] {InlineKeyboardButton.WithCallbackData(strings.decrease_number_of_players, $"{strings.decrease_number_of_players_callback}|{userId}"), InlineKeyboardButton.WithCallbackData(strings.increase_number_of_players, $"{strings.increase_number_of_players_callback}|{userId}")}
+                new[] {InlineKeyboardButton.WithCallbackData(strings.decrease_number_of_players, $"{callback.decrease_number_of_players}|{userId}"),
+                    InlineKeyboardButton.WithCallbackData(strings.increase_number_of_players, $"{callback.increase_number_of_players}|{userId}")}
             });
 
             var reply = await Bot.SendWithMarkdown2(chatId, message, inlineKeyboard);

+ 6 - 5
MafiaTelegramBot/Models/Commands/ShowProfileCommand.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Threading.Tasks;
 using MafiaTelegramBot.DataBase;
+using MafiaTelegramBot.Resources;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
 using Telegram.Bot.Types.ReplyMarkups;
@@ -9,7 +10,7 @@ namespace MafiaTelegramBot.Models.Commands
 {
     public class ShowProfileCommand : Command
     {
-        protected override string Name => strings.show_profile;
+        protected override string Name => keyboard.show_profile;
 
         public override async Task<Message> Execute(Update update)
         {
@@ -19,17 +20,17 @@ namespace MafiaTelegramBot.Models.Commands
             var user = await UserDao.GetUserById(userId);
             var winRate = user.Games < 1 ? 0.0 : Convert.ToDouble(user.Wins) / Convert.ToDouble(user.Games);
             var message =
-                $"__*{strings.statistics_for} _{user.Username}_*__\n" +
+                $"__*{strings.statistics_for} _{user.NickName}_*__\n" +
                 $"{strings.games_count} {user.Games}\n" +
                 $"{strings.wins_count} {user.Wins}\n" +
                 $"{strings.winrate} {winRate}%\n";
             var inlineKeyboard = new InlineKeyboardMarkup(new[]
             {
                 new[] {
-                    InlineKeyboardButton.WithCallbackData(strings.shop, $"{strings.shop_callback}|{userId}"),
-                    InlineKeyboardButton.WithCallbackData(strings.my_roles, $"{strings.my_roles_callback}|{userId}")
+                    InlineKeyboardButton.WithCallbackData(strings.shop, $"{callback.shop}|{userId}"),
+                    InlineKeyboardButton.WithCallbackData(strings.my_roles, $"{callback.my_roles}|{userId}")
                 },
-                new[] {InlineKeyboardButton.WithCallbackData(strings.settings, $"{strings.settings_callback}|{userId}")}
+                new[] {InlineKeyboardButton.WithCallbackData(strings.settings, $"{callback.settings_profile}|{userId}")}
             });
             return await Bot.SendWithMarkdown2(chatId, message, inlineKeyboard);
         }

+ 33 - 54
MafiaTelegramBot/Models/Commands/StartCommand.cs

@@ -1,8 +1,8 @@
 using System.Threading.Tasks;
 using MafiaTelegramBot.DataBase;
+using MafiaTelegramBot.Resources;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
-using Telegram.Bot.Types.ReplyMarkups;
 
 namespace MafiaTelegramBot.Models.Commands
 {
@@ -13,64 +13,43 @@ namespace MafiaTelegramBot.Models.Commands
         public override async Task<Message> Execute(Update update)
         {
             var chatId = update.Message.Chat.Id;
-            await Bot.Get().SendChatActionAsync(chatId, ChatAction.Typing);
-            ReplyKeyboardMarkup keyboard = new(
-                new[]
-                {
-                    new KeyboardButton[] {strings.create_game},
-                    new KeyboardButton[] {strings.connect_game},
-                    new KeyboardButton[] {strings.show_profile}
-                },
-                true
-            );
-            var message = await Bot.SendWithMarkdown2(chatId, strings.start_message, keyboard);
             var userId = update.Message.From.Id;
-            var username = update.Message.From.Username;
-            username = username != null ?await Task.Run(()=> username
-                .Replace(".", "\\.")
-                .Replace("`", "\\`")
-                .Replace("@", "\\@")
-                .Replace("#", "\\#")
-                .Replace("!", "\\!")
-                .Replace("*", "\\*")
-                .Replace("_", "\\_")
-                .Replace("'", "\\'")
-                .Replace("~", "\\~")
-                .Replace("[", "\\[")
-            ):"";
-            var firstName = update.Message.From.FirstName;
-            firstName = firstName != null ?await Task.Run(()=> firstName
-                .Replace(".", "\\.")
-                .Replace("`", "\\`")
-                .Replace("@", "\\@")
-                .Replace("#", "\\#")
-                .Replace("!", "\\!")
-                .Replace("*", "\\*")
-                .Replace("_", "\\_")
-                .Replace("'", "\\'")
-                .Replace("~", "\\~")
-                .Replace("[", "\\[")
-            ):"";
-            var lastName = update.Message.From.LastName;
-            lastName = lastName != null ?await Task.Run(()=> lastName
-                .Replace(".", "\\.")
-                .Replace("`", "\\`")
-                .Replace("@", "\\@")
-                .Replace("#", "\\#")
-                .Replace("!", "\\!")
-                .Replace("*", "\\*")
-                .Replace("_", "\\_")
-                .Replace("'", "\\'")
-                .Replace("~", "\\~")
-                .Replace("[", "\\[")
-            ):"";
-            if (await UserDao.UserExists(userId)) return message;
+            await Bot.Get().SendChatActionAsync(chatId, ChatAction.Typing);
+            if (await UserDao.UserExists(userId))
+            {
+                var player = await UserDao.GetUserById(userId);
+                if (player.GetRoomKey() != "")
+                    return await Bot.SendWithMarkdown2(chatId, $"{strings.prefer_leave_from_room} {await player.GetRoomName()}");
+                return await Bot.SendWithMarkdown2(chatId, strings.start_message, Keyboards.MainMenu);
+            } 
+            var username = await EscapeSpecific(update.Message.From.Username);
+            var firstName = await EscapeSpecific(update.Message.From.FirstName);
+            var lastName = await EscapeSpecific(update.Message.From.LastName);
             var user = new DataBase.User
             {
-                Id = userId, ChatId = chatId, Username = username, FirstName =  firstName, LastName = lastName
+                Id = userId, ChatId = chatId, Username = username, NickName =  $"{firstName} {lastName}"
             };
             await UserDao.Update(user);
-            return message;
+            return await Bot.SendWithMarkdown2(chatId, strings.start_message, Keyboards.MainMenu);
+        }
+
+        private static async Task<string> EscapeSpecific(string src)
+        {
+            var result = src != null
+                ? await Task.Run(()=> src
+                    .Replace(".", "\\.")
+                    .Replace("`", "\\`")
+                    .Replace("@", "\\@")
+                    .Replace("#", "\\#")
+                    .Replace("!", "\\!")
+                    .Replace("*", "\\*")
+                    .Replace("_", "\\_")
+                    .Replace("'", "\\'")
+                    .Replace("~", "\\~")
+                    .Replace("[", "\\[")
+                )
+                :"";
+            return result;
         }
     }
 }

+ 2 - 1
MafiaTelegramBot/Models/Inlines/ChangeNameQuery.cs

@@ -1,4 +1,5 @@
 using System.Threading.Tasks;
+using MafiaTelegramBot.Resources;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
 
@@ -6,7 +7,7 @@ namespace MafiaTelegramBot.Models.Inlines
 {
     public class ChangeNameQuery : Query
     {
-        protected override string Name => strings.change_name_callback;
+        protected override string Name => callback.change_name;
 
         public override async Task<Message> Execute(Update update)
         {

+ 1 - 3
MafiaTelegramBot/Models/Inlines/ConnectToPrivateRoomQuery.cs

@@ -1,6 +1,4 @@
 using System.Threading.Tasks;
-using MafiaTelegramBot.Controllers;
-using MafiaTelegramBot.DataBase;
 using MafiaTelegramBot.Resources;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
@@ -9,7 +7,7 @@ namespace MafiaTelegramBot.Models.Inlines
 {
     public class ConnectToPrivateRoomQuery : Query
     {
-        protected override string Name => strings.connect_to_private_room_callback;
+        protected override string Name => callback.connect_to_private_room;
         public override async Task<Message> Execute(Update update)
         {
             await DeletePreviousMessage(update.CallbackQuery.Message.Chat.Id, update.CallbackQuery.Message.MessageId);

+ 13 - 19
MafiaTelegramBot/Models/Inlines/ConnectToPublicRoomQuery.cs

@@ -1,7 +1,6 @@
-using System.Collections;
-using System.Collections.Generic;
 using System.Threading.Tasks;
 using MafiaTelegramBot.Controllers;
+using MafiaTelegramBot.Resources;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
 using Telegram.Bot.Types.ReplyMarkups;
@@ -10,7 +9,7 @@ namespace MafiaTelegramBot.Models.Inlines
 {
     public class ConnectToPublicRoomQuery : Query
     {
-        protected override string Name => strings.connect_to_public_room_callback;
+        protected override string Name => callback.connect_to_public_room;
         public override async Task<Message> Execute(Update update)
         {
             await DeletePreviousMessage(update.CallbackQuery.Message.Chat.Id, update.CallbackQuery.Message.MessageId);
@@ -20,25 +19,20 @@ namespace MafiaTelegramBot.Models.Inlines
             var param = data.Split('|');
             var userId = long.Parse(param[1]);
             var rooms = await RoomController.GetPublicRooms();
-            if (rooms.Count != 0)
+            if (rooms.Count == 0) return await Bot.SendWithMarkdown2(chatId, strings.public_rooms_are_not_exist);
+            var inlineButtons = new InlineKeyboardButton[rooms.Count];
+            for (var i = 0; i < rooms.Count; ++i) // buttons
             {
-                
-                
-                InlineKeyboardButton[] inlineButtons = new InlineKeyboardButton[rooms.Count];
-                for (var i = 0; i < rooms.Count; ++i) // buttons
+                inlineButtons[i] = new InlineKeyboardButton
                 {
-                    inlineButtons[i] = new InlineKeyboardButton
-                    {
-                        Text =
-                            $"{rooms[i].RoomName} ({rooms[i].Players.Values.Count.ToString()}/{rooms[i].MaxPlayers.ToString()})",
-                        CallbackData = $"{strings.connect_to_selected_room_callback}|{userId}|{rooms[i].RoomName}"
-                    };
-                }
-
-                var inlineKeyboard = new InlineKeyboardMarkup(inlineButtons);
-                return await Bot.SendWithMarkdown2(chatId, strings.rooms, inlineKeyboard);
+                    Text =
+                        $"{rooms[i].RoomName} ({rooms[i].Players.Values.Count.ToString()}/{rooms[i].MaxPlayers.ToString()})",
+                    CallbackData = $"{callback.connect_to_selected_room}|{userId}|{rooms[i].RoomName}"
+                };
             }
-            return await Bot.SendWithMarkdown2(chatId, strings.public_rooms_are_not_exist);
+
+            var inlineKeyboard = new InlineKeyboardMarkup(inlineButtons);
+            return await Bot.SendWithMarkdown2(chatId, strings.rooms, inlineKeyboard);
         }
     }
 }

+ 8 - 17
MafiaTelegramBot/Models/Inlines/ConnectToSelectedRoomQuery.cs

@@ -1,16 +1,16 @@
+using System.Linq;
 using System.Threading.Tasks;
 using MafiaTelegramBot.Controllers;
 using MafiaTelegramBot.DataBase;
 using MafiaTelegramBot.Resources;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
-using Telegram.Bot.Types.ReplyMarkups;
 
 namespace MafiaTelegramBot.Models.Inlines
 {
     public class ConnectToSelectedRoomQuery : Query
     {
-        protected override string Name => strings.connect_to_selected_room_callback;
+        protected override string Name => callback.connect_to_selected_room;
         public override async Task<Message> Execute(Update update)
         {
             await DeletePreviousMessage(update.CallbackQuery.Message.Chat.Id, update.CallbackQuery.Message.MessageId);
@@ -24,27 +24,18 @@ namespace MafiaTelegramBot.Models.Inlines
             var resultCode = await RoomController.ConnectToGame(user, roomName);
             switch (resultCode)
             {
-                case Constants.CODE_OK:
+                case ResultCode.CodeOk:
                 {
                     var users = await RoomController.GetPlayers(roomName);
-                    foreach (var player in users)
+                    foreach (var player in users.Where(player => userId != player.Id))
                     {
-                        if (userId == player.Id) continue;
-                        await Bot.SendWithMarkdown2(player.ChatId, $"{strings.entry_another_user} _*{user?.Username}*_");
+                        await Bot.SendWithMarkdown2(player.ChatId, $"{strings.entry_another_user} _*{user.NickName}*_");
                     }
-                    var keyboard = new InlineKeyboardMarkup(new []
-                    {
-                        new []{
-                            InlineKeyboardButton.WithCallbackData(strings.look_user_list, $"{strings.look_user_list_callback}|{userId}|{roomName}"),
-                            //TODO сделать другой выход из комнаты
-                            InlineKeyboardButton.WithCallbackData(strings.leave, $"{strings.leave_callback}|{userId}")
-                        }
-                    });
-                    return await Bot.SendWithMarkdown2(chatId, strings.successful_entry_into_room, keyboard);
+                    return await Bot.SendWithMarkdown2(chatId, strings.successful_entry_into_room, Keyboards.PlayerGameMenu);
                 }
-                case Constants.ROOM_IS_FILLED:
+                case ResultCode.RoomIsFilled:
                     return await Bot.SendWithMarkdown2(chatId, strings.room_is_filled);
-                case Constants.USER_ALREADY_IN_GAME:
+                case ResultCode.UserAlreadyInGame:
                     return await Bot.SendWithMarkdown2(chatId, strings.user_already_in_game);
                 default:
                     return await Bot.SendWithMarkdown2(chatId, strings.unexpected_error);

+ 3 - 2
MafiaTelegramBot/Models/Inlines/DecreaseRoomMaxCapacity.cs

@@ -9,7 +9,7 @@ namespace MafiaTelegramBot.Models.Inlines
 {
     public class DecreaseRoomMaxCapacity:Query
     {
-        protected override string Name => strings.decrease_number_of_players_callback;
+        protected override string Name => callback.decrease_number_of_players;
         public override async Task<Message> Execute(Update update)
         {
             var messageId = update.CallbackQuery.Message.MessageId;
@@ -32,7 +32,8 @@ namespace MafiaTelegramBot.Models.Inlines
             
             var inlineKeyboard = new InlineKeyboardMarkup(new[]
             {
-                new[] {InlineKeyboardButton.WithCallbackData(strings.decrease_number_of_players, $"{strings.decrease_number_of_players_callback}|{userId}"), InlineKeyboardButton.WithCallbackData(strings.increase_number_of_players, $"{strings.increase_number_of_players_callback}|{userId}")}
+                new[] {InlineKeyboardButton.WithCallbackData(strings.decrease_number_of_players, $"{callback.decrease_number_of_players}|{userId}"),
+                    InlineKeyboardButton.WithCallbackData(strings.increase_number_of_players, $"{callback.increase_number_of_players}|{userId}")}
             });
             
             return await Bot.Get().EditMessageTextAsync(chatId, messageId, message, replyMarkup:inlineKeyboard);

+ 3 - 2
MafiaTelegramBot/Models/Inlines/IncreaseRoomMaxCapacityQuery.cs

@@ -9,7 +9,7 @@ namespace MafiaTelegramBot.Models.Inlines
 {
     public class IncreaseRoomMaxCapacityQuery : Query
     {
-        protected override string Name => strings.increase_number_of_players_callback;
+        protected override string Name => callback.increase_number_of_players;
 
         public override async Task<Message> Execute(Update update)
         {
@@ -34,7 +34,8 @@ namespace MafiaTelegramBot.Models.Inlines
             
             var inlineKeyboard = new InlineKeyboardMarkup(new[]
             {
-                new[] {InlineKeyboardButton.WithCallbackData(strings.decrease_number_of_players, $"{strings.decrease_number_of_players_callback}|{userId}"), InlineKeyboardButton.WithCallbackData(strings.increase_number_of_players, $"{strings.increase_number_of_players_callback}|{userId}")}
+                new[] {InlineKeyboardButton.WithCallbackData(strings.decrease_number_of_players, $"{callback.decrease_number_of_players}|{userId}"),
+                    InlineKeyboardButton.WithCallbackData(strings.increase_number_of_players, $"{callback.increase_number_of_players}|{userId}")}
             });
             
             return await Bot.Get().EditMessageTextAsync(chatId, messageId, message, replyMarkup:inlineKeyboard);

+ 0 - 41
MafiaTelegramBot/Models/Inlines/LookUsersListQuery.cs

@@ -1,41 +0,0 @@
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using MafiaTelegramBot.Controllers;
-using Microsoft.VisualBasic;
-using Telegram.Bot.Types;
-using Telegram.Bot.Types.Enums;
-
-namespace MafiaTelegramBot.Models.Inlines
-{
-    public class LookUsersListQuery :Query
-    {
-        protected override string Name => strings.look_user_list_callback;
-        public override async Task<Message> Execute(Update update)
-        {
-            var chatId = update.CallbackQuery.Message.Chat.Id;
-            await Bot.Get().SendChatActionAsync(chatId, ChatAction.Typing);
-            var data = update.CallbackQuery.Data;
-            var param = data.Split('|');
-            var userId = long.Parse(param[1]);
-            var roomKey = param[2];
-            var users = await RoomController.GetPlayers(roomKey);
-            string s = "";
-            if (users.Count > 1)
-            {
-                s = strings.users_list;
-                foreach (var player in users)
-                {
-                    if (player.Id == userId) continue;
-                    s += $"\n \n {player.Username} \n{player.FirstName} {player.LastName}";
-                     
-                }
-            }
-            else
-            {
-                s = strings.users_list_empty;
-            }
-
-            return await Bot.SendWithMarkdown2(chatId, s);
-        }
-    }
-}

+ 2 - 1
MafiaTelegramBot/Models/Inlines/MakeExtendedGameQuery.cs

@@ -1,5 +1,6 @@
 using System.Threading.Tasks;
 using MafiaTelegramBot.DataBase;
+using MafiaTelegramBot.Resources;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
 
@@ -7,7 +8,7 @@ namespace MafiaTelegramBot.Models.Inlines
 {
     public class MakeExtendedGameQuery : Query
     {
-        protected override string Name => strings.extended_callback;
+        protected override string Name => callback.extended;
         public override async Task<Message> Execute(Update update)
         {
             await DeletePreviousMessage(update.CallbackQuery.Message.Chat.Id, update.CallbackQuery.Message.MessageId);

+ 4 - 3
MafiaTelegramBot/Models/Inlines/MakePrivateRoomQuery.cs

@@ -1,5 +1,6 @@
 using System.Threading.Tasks;
 using MafiaTelegramBot.DataBase;
+using MafiaTelegramBot.Resources;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
 using Telegram.Bot.Types.ReplyMarkups;
@@ -8,7 +9,7 @@ namespace MafiaTelegramBot.Models.Inlines
 {
     public class MakePrivateRoomQuery : Query
     {
-        protected override string Name => strings.make_private_room_callback;
+        protected override string Name => callback.make_private_room;
         public override async Task<Message> Execute(Update update)
         {
             await DeletePreviousMessage(update.CallbackQuery.Message.Chat.Id, update.CallbackQuery.Message.MessageId);
@@ -22,8 +23,8 @@ namespace MafiaTelegramBot.Models.Inlines
             var inlineKeyboard = new InlineKeyboardMarkup(new[]
             {
                 new[] {
-                    InlineKeyboardButton.WithCallbackData(strings.standart, $"{strings.standart_callback}|{userId}|private"),
-                    InlineKeyboardButton.WithCallbackData(strings.extended, $"{strings.extended_callback}|{userId}|private")
+                    InlineKeyboardButton.WithCallbackData(strings.standart, $"{callback.standart}|{userId}|private"),
+                    InlineKeyboardButton.WithCallbackData(strings.extended, $"{callback.extended}|{userId}|private")
                 }
             });
             return await Bot.SendWithMarkdown2(chatId, strings.choose_game_type, inlineKeyboard);

+ 4 - 3
MafiaTelegramBot/Models/Inlines/MakePublicRoomQuery.cs

@@ -1,5 +1,6 @@
 using System.Threading.Tasks;
 using MafiaTelegramBot.DataBase;
+using MafiaTelegramBot.Resources;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
 using Telegram.Bot.Types.ReplyMarkups;
@@ -8,7 +9,7 @@ namespace MafiaTelegramBot.Models.Inlines
 {
     public class MakePublicRoomQuery : Query
     {
-        protected override string Name => strings.make_public_room_callback;
+        protected override string Name => callback.make_public_room;
         public override async Task<Message> Execute(Update update)
         { 
             await DeletePreviousMessage(update.CallbackQuery.Message.Chat.Id, update.CallbackQuery.Message.MessageId);
@@ -22,8 +23,8 @@ namespace MafiaTelegramBot.Models.Inlines
             var inlineKeyboard = new InlineKeyboardMarkup(new[]
             {
                 new[] {
-                    InlineKeyboardButton.WithCallbackData(strings.standart, $"{strings.standart_callback}|{userId}|public"),
-                    InlineKeyboardButton.WithCallbackData(strings.extended, $"{strings.extended_callback}|{userId}|public")
+                    InlineKeyboardButton.WithCallbackData(strings.standart, $"{callback.standart}|{userId}|public"),
+                    InlineKeyboardButton.WithCallbackData(strings.extended, $"{callback.extended}|{userId}|public")
                 }
             });
             return await Bot.SendWithMarkdown2(chatId, strings.choose_game_type, inlineKeyboard);

+ 2 - 1
MafiaTelegramBot/Models/Inlines/MakeStandartGameQuery.cs

@@ -1,5 +1,6 @@
 using System.Threading.Tasks;
 using MafiaTelegramBot.DataBase;
+using MafiaTelegramBot.Resources;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
 
@@ -7,7 +8,7 @@ namespace MafiaTelegramBot.Models.Inlines
 {
     public class MakeStandartGameQuery : Query
     {
-        protected override string Name => strings.standart_callback;
+        protected override string Name => callback.standart;
         public override async Task<Message> Execute(Update update)
         {
             await DeletePreviousMessage(update.CallbackQuery.Message.Chat.Id, update.CallbackQuery.Message.MessageId);

+ 3 - 2
MafiaTelegramBot/Models/Inlines/MyRolesQuery.cs

@@ -1,4 +1,5 @@
 using System.Threading.Tasks;
+using MafiaTelegramBot.Resources;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
 
@@ -6,14 +7,14 @@ namespace MafiaTelegramBot.Models.Inlines
 {
     public class MyRolesQuery : Query
     {
-        protected override string Name => strings.my_roles_callback;
+        protected override string Name => callback.my_roles;
 
         public override async Task<Message> Execute(Update update)
         {
             await DeletePreviousMessage(update.CallbackQuery.Message.Chat.Id, update.CallbackQuery.Message.MessageId);
             var chatId = update.CallbackQuery.Message.Chat.Id;
             await Bot.Get().SendChatActionAsync(chatId, ChatAction.Typing);
-            return await Bot.SendWithMarkdown2(chatId, Name);
+            return await Bot.SendWithMarkdown2(chatId, strings.my_roles);
         }
     }
 }

+ 4 - 3
MafiaTelegramBot/Models/Inlines/SettingsQuery.cs

@@ -1,5 +1,6 @@
 using System.Threading.Tasks;
 using MafiaTelegramBot.DataBase;
+using MafiaTelegramBot.Resources;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
 using Telegram.Bot.Types.ReplyMarkups;
@@ -8,7 +9,7 @@ namespace MafiaTelegramBot.Models.Inlines
 {
     public class SettingsQuery : Query
     {
-        protected override string Name => strings.settings_callback;
+        protected override string Name => callback.settings_profile;
 
         public override async Task<Message> Execute(Update update)
         {
@@ -17,8 +18,8 @@ namespace MafiaTelegramBot.Models.Inlines
             await Bot.Get().SendChatActionAsync(chatId, ChatAction.Typing);
             var userId = update.CallbackQuery.From.Id;
             var user = await UserDao.GetUserById(userId);
-            var inlineKeyboard = new InlineKeyboardMarkup(InlineKeyboardButton.WithCallbackData(strings.change_name, $"{strings.change_name_callback}|{userId}"));
-            return await Bot.SendWithMarkdown2(chatId, $"{strings.your_name} {user.Username}", inlineKeyboard);
+            var inlineKeyboard = new InlineKeyboardMarkup(InlineKeyboardButton.WithCallbackData(strings.change_name, $"{callback.change_name}|{userId}"));
+            return await Bot.SendWithMarkdown2(chatId, $"{strings.your_name} {user.NickName}", inlineKeyboard);
         }
     }
 }

+ 2 - 1
MafiaTelegramBot/Models/Inlines/SettingsRoomQuery.cs

@@ -1,4 +1,5 @@
 using System.Threading.Tasks;
+using MafiaTelegramBot.Resources;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
 
@@ -6,7 +7,7 @@ namespace MafiaTelegramBot.Models.Inlines
 {
     public class SettingsRoomQuery : Query
     {
-        protected override string Name => strings.settings_room_callback;
+        protected override string Name => callback.settings_room;
         public override async Task<Message> Execute(Update update)
         {
             var chatId = update.CallbackQuery.Message.Chat.Id;

+ 3 - 2
MafiaTelegramBot/Models/Inlines/ShopQuery.cs

@@ -1,4 +1,5 @@
 using System.Threading.Tasks;
+using MafiaTelegramBot.Resources;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
 
@@ -6,14 +7,14 @@ namespace MafiaTelegramBot.Models.Inlines
 {
     public class ShopQuery : Query
     {
-        protected override string Name => strings.shop_callback;
+        protected override string Name => callback.shop;
 
         public override async Task<Message> Execute(Update update)
         {
             await DeletePreviousMessage(update.CallbackQuery.Message.Chat.Id, update.CallbackQuery.Message.MessageId);
             var chatId = update.CallbackQuery.Message.Chat.Id;
             await Bot.Get().SendChatActionAsync(chatId, ChatAction.Typing);
-            return await Bot.SendWithMarkdown2(chatId, Name);
+            return await Bot.SendWithMarkdown2(chatId, strings.shop);
         }
     }
 }

+ 29 - 0
MafiaTelegramBot/Resources/Keyboards.cs

@@ -0,0 +1,29 @@
+using Telegram.Bot.Types.ReplyMarkups;
+
+namespace MafiaTelegramBot.Resources
+{
+    public static class Keyboards
+    {
+        public static readonly ReplyKeyboardMarkup MainMenu = new(new[]
+            {
+                new KeyboardButton[] {keyboard.create_game},
+                new KeyboardButton[] {keyboard.connect_game, keyboard.show_profile}
+            }, true
+        );
+        
+        public static readonly ReplyKeyboardMarkup OwnerGameMenu = new(new[]
+            {
+                new KeyboardButton[] {keyboard.begin_game, keyboard.room_settings},
+                new KeyboardButton[] {keyboard.kick_player, keyboard.look_players_list},
+                new KeyboardButton[] {keyboard.show_profile, keyboard.leave}
+            }, true
+        );
+        
+        public static readonly ReplyKeyboardMarkup PlayerGameMenu = new(new[]
+            {
+                new KeyboardButton[] {keyboard.show_profile, keyboard.look_players_list},
+                new KeyboardButton[] {keyboard.leave}
+            }, true
+        );
+    }
+}

+ 189 - 0
MafiaTelegramBot/Resources/callback.Designer.cs

@@ -0,0 +1,189 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.42000
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace MafiaTelegramBot.Resources {
+    using System;
+    
+    
+    /// <summary>
+    ///   A strongly-typed resource class, for looking up localized strings, etc.
+    /// </summary>
+    // This class was auto-generated by the StronglyTypedResourceBuilder
+    // class via a tool like ResGen or Visual Studio.
+    // To add or remove a member, edit your .ResX file then rerun ResGen
+    // with the /str option, or rebuild your VS project.
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class callback {
+        
+        private static global::System.Resources.ResourceManager resourceMan;
+        
+        private static global::System.Globalization.CultureInfo resourceCulture;
+        
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal callback() {
+        }
+        
+        /// <summary>
+        ///   Returns the cached ResourceManager instance used by this class.
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager {
+            get {
+                if (object.ReferenceEquals(resourceMan, null)) {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MafiaTelegramBot.Resources.callback", typeof(callback).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+        
+        /// <summary>
+        ///   Overrides the current thread's CurrentUICulture property for all
+        ///   resource lookups using this strongly typed resource class.
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture {
+            get {
+                return resourceCulture;
+            }
+            set {
+                resourceCulture = value;
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to change_name.
+        /// </summary>
+        internal static string change_name {
+            get {
+                return ResourceManager.GetString("change_name", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to connect_to_private_room.
+        /// </summary>
+        internal static string connect_to_private_room {
+            get {
+                return ResourceManager.GetString("connect_to_private_room", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to connect_to_public_room.
+        /// </summary>
+        internal static string connect_to_public_room {
+            get {
+                return ResourceManager.GetString("connect_to_public_room", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to connect_to_selected_room.
+        /// </summary>
+        internal static string connect_to_selected_room {
+            get {
+                return ResourceManager.GetString("connect_to_selected_room", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to decrease_number_of_players.
+        /// </summary>
+        internal static string decrease_number_of_players {
+            get {
+                return ResourceManager.GetString("decrease_number_of_players", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to extended.
+        /// </summary>
+        internal static string extended {
+            get {
+                return ResourceManager.GetString("extended", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to increase_number_of_players.
+        /// </summary>
+        internal static string increase_number_of_players {
+            get {
+                return ResourceManager.GetString("increase_number_of_players", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to make_private_room.
+        /// </summary>
+        internal static string make_private_room {
+            get {
+                return ResourceManager.GetString("make_private_room", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to make_public_room.
+        /// </summary>
+        internal static string make_public_room {
+            get {
+                return ResourceManager.GetString("make_public_room", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to my_roles.
+        /// </summary>
+        internal static string my_roles {
+            get {
+                return ResourceManager.GetString("my_roles", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to settings_profile.
+        /// </summary>
+        internal static string settings_profile {
+            get {
+                return ResourceManager.GetString("settings_profile", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to settings_room.
+        /// </summary>
+        internal static string settings_room {
+            get {
+                return ResourceManager.GetString("settings_room", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to shop.
+        /// </summary>
+        internal static string shop {
+            get {
+                return ResourceManager.GetString("shop", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to standart.
+        /// </summary>
+        internal static string standart {
+            get {
+                return ResourceManager.GetString("standart", resourceCulture);
+            }
+        }
+    }
+}

+ 63 - 0
MafiaTelegramBot/Resources/callback.resx

@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<root>
+    <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+        <xsd:element name="root" msdata:IsDataSet="true">
+            
+        </xsd:element>
+    </xsd:schema>
+    <resheader name="resmimetype">
+        <value>text/microsoft-resx</value>
+    </resheader>
+    <resheader name="version">
+        <value>1.3</value>
+    </resheader>
+    <resheader name="reader">
+        <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    </resheader>
+    <resheader name="writer">
+        <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    </resheader>
+    <data name="change_name" xml:space="preserve">
+        <value>change_name</value>
+    </data>
+    <data name="connect_to_private_room" xml:space="preserve">
+        <value>connect_to_private_room</value>
+    </data>
+    <data name="decrease_number_of_players" xml:space="preserve">
+        <value>decrease_number_of_players</value>
+    </data>
+    <data name="increase_number_of_players" xml:space="preserve">
+        <value>increase_number_of_players</value>
+    </data>
+    <data name="connect_to_public_room" xml:space="preserve">
+        <value>connect_to_public_room</value>
+    </data>
+    <data name="make_public_room" xml:space="preserve">
+        <value>make_public_room</value>
+    </data>
+    <data name="make_private_room" xml:space="preserve">
+        <value>make_private_room</value>
+    </data>
+    <data name="extended" xml:space="preserve">
+        <value>extended</value>
+    </data>
+    <data name="shop" xml:space="preserve">
+        <value>shop</value>
+    </data>
+    <data name="my_roles" xml:space="preserve">
+        <value>my_roles</value>
+    </data>
+    <data name="settings_profile" xml:space="preserve">
+        <value>settings_profile</value>
+    </data>
+    <data name="standart" xml:space="preserve">
+        <value>standart</value>
+    </data>
+    <data name="settings_room" xml:space="preserve">
+        <value>settings_room</value>
+    </data>
+    <data name="connect_to_selected_room" xml:space="preserve">
+        <value>connect_to_selected_room</value>
+    </data>
+</root>

+ 135 - 0
MafiaTelegramBot/Resources/keyboard.Designer.cs

@@ -0,0 +1,135 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.42000
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace MafiaTelegramBot.Resources {
+    using System;
+    
+    
+    /// <summary>
+    ///   A strongly-typed resource class, for looking up localized strings, etc.
+    /// </summary>
+    // This class was auto-generated by the StronglyTypedResourceBuilder
+    // class via a tool like ResGen or Visual Studio.
+    // To add or remove a member, edit your .ResX file then rerun ResGen
+    // with the /str option, or rebuild your VS project.
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class keyboard {
+        
+        private static global::System.Resources.ResourceManager resourceMan;
+        
+        private static global::System.Globalization.CultureInfo resourceCulture;
+        
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal keyboard() {
+        }
+        
+        /// <summary>
+        ///   Returns the cached ResourceManager instance used by this class.
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager {
+            get {
+                if (object.ReferenceEquals(resourceMan, null)) {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MafiaTelegramBot.Resources.keyboard", typeof(keyboard).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+        
+        /// <summary>
+        ///   Overrides the current thread's CurrentUICulture property for all
+        ///   resource lookups using this strongly typed resource class.
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture {
+            get {
+                return resourceCulture;
+            }
+            set {
+                resourceCulture = value;
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Начать игру.
+        /// </summary>
+        internal static string begin_game {
+            get {
+                return ResourceManager.GetString("begin_game", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Подключиться.
+        /// </summary>
+        internal static string connect_game {
+            get {
+                return ResourceManager.GetString("connect_game", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Создать игру.
+        /// </summary>
+        internal static string create_game {
+            get {
+                return ResourceManager.GetString("create_game", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Исключить игрока.
+        /// </summary>
+        internal static string kick_player {
+            get {
+                return ResourceManager.GetString("kick_player", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Покинуть игру.
+        /// </summary>
+        internal static string leave {
+            get {
+                return ResourceManager.GetString("leave", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Список игроков.
+        /// </summary>
+        internal static string look_players_list {
+            get {
+                return ResourceManager.GetString("look_players_list", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Настрокйи комнаты.
+        /// </summary>
+        internal static string room_settings {
+            get {
+                return ResourceManager.GetString("room_settings", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Мой профиль.
+        /// </summary>
+        internal static string show_profile {
+            get {
+                return ResourceManager.GetString("show_profile", resourceCulture);
+            }
+        }
+    }
+}

+ 45 - 0
MafiaTelegramBot/Resources/keyboard.resx

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<root>
+    <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+        <xsd:element name="root" msdata:IsDataSet="true">
+            
+        </xsd:element>
+    </xsd:schema>
+    <resheader name="resmimetype">
+        <value>text/microsoft-resx</value>
+    </resheader>
+    <resheader name="version">
+        <value>1.3</value>
+    </resheader>
+    <resheader name="reader">
+        <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    </resheader>
+    <resheader name="writer">
+        <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    </resheader>
+    <data name="connect_game" xml:space="preserve">
+        <value>Подключиться</value>
+    </data>
+    <data name="look_players_list" xml:space="preserve">
+        <value>Список игроков</value>
+    </data>
+    <data name="create_game" xml:space="preserve">
+        <value>Создать игру</value>
+    </data>
+    <data name="show_profile" xml:space="preserve">
+        <value>Мой профиль</value>
+    </data>
+    <data name="begin_game" xml:space="preserve">
+        <value>Начать игру</value>
+    </data>
+    <data name="room_settings" xml:space="preserve">
+        <value>Настрокйи комнаты</value>
+    </data>
+    <data name="kick_player" xml:space="preserve">
+        <value>Исключить игрока</value>
+    </data>
+    <data name="leave" xml:space="preserve">
+        <value>Покинуть игру</value>
+    </data>
+</root>

+ 20 - 227
MafiaTelegramBot/Resources/strings.Designer.cs

@@ -69,15 +69,6 @@ namespace MafiaTelegramBot {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to Начать игру.
-        /// </summary>
-        internal static string begin_game {
-            get {
-                return ResourceManager.GetString("begin_game", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Сменить имя.
         /// </summary>
@@ -87,15 +78,6 @@ namespace MafiaTelegramBot {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to change_name.
-        /// </summary>
-        internal static string change_name_callback {
-            get {
-                return ResourceManager.GetString("change_name_callback", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Выберите режим игры.
         /// </summary>
@@ -123,15 +105,6 @@ namespace MafiaTelegramBot {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to Присоединиться к игре.
-        /// </summary>
-        internal static string connect_game {
-            get {
-                return ResourceManager.GetString("connect_game", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Приватная комната.
         /// </summary>
@@ -141,15 +114,6 @@ namespace MafiaTelegramBot {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to connect_to_private_room.
-        /// </summary>
-        internal static string connect_to_private_room_callback {
-            get {
-                return ResourceManager.GetString("connect_to_private_room_callback", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Публичная комната.
         /// </summary>
@@ -159,33 +123,6 @@ namespace MafiaTelegramBot {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to connect_to_public_room.
-        /// </summary>
-        internal static string connect_to_public_room_callback {
-            get {
-                return ResourceManager.GetString("connect_to_public_room_callback", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to connect_to_selected_room_callback.
-        /// </summary>
-        internal static string connect_to_selected_room_callback {
-            get {
-                return ResourceManager.GetString("connect_to_selected_room_callback", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Создать игру.
-        /// </summary>
-        internal static string create_game {
-            get {
-                return ResourceManager.GetString("create_game", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to -.
         /// </summary>
@@ -195,15 +132,6 @@ namespace MafiaTelegramBot {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to lower_number_of_players.
-        /// </summary>
-        internal static string decrease_number_of_players_callback {
-            get {
-                return ResourceManager.GetString("decrease_number_of_players_callback", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Введите код от комнаты.
         /// </summary>
@@ -249,24 +177,6 @@ namespace MafiaTelegramBot {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to extended.
-        /// </summary>
-        internal static string extended_callback {
-            get {
-                return ResourceManager.GetString("extended_callback", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Игра уже идёт.
-        /// </summary>
-        internal static string game_is_runing {
-            get {
-                return ResourceManager.GetString("game_is_runing", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Число игр:.
         /// </summary>
@@ -285,42 +195,6 @@ namespace MafiaTelegramBot {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to increase_number_of_players.
-        /// </summary>
-        internal static string increase_number_of_players_callback {
-            get {
-                return ResourceManager.GetString("increase_number_of_players_callback", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Исключить игрока.
-        /// </summary>
-        internal static string kick_player {
-            get {
-                return ResourceManager.GetString("kick_player", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Выйти.
-        /// </summary>
-        internal static string leave {
-            get {
-                return ResourceManager.GetString("leave", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to leave.
-        /// </summary>
-        internal static string leave_callback {
-            get {
-                return ResourceManager.GetString("leave_callback", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Вы покинули игру.
         /// </summary>
@@ -330,24 +204,6 @@ namespace MafiaTelegramBot {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to Список игроков.
-        /// </summary>
-        internal static string look_user_list {
-            get {
-                return ResourceManager.GetString("look_user_list", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to look_user_list.
-        /// </summary>
-        internal static string look_user_list_callback {
-            get {
-                return ResourceManager.GetString("look_user_list_callback", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Приватная комната.
         /// </summary>
@@ -357,15 +213,6 @@ namespace MafiaTelegramBot {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to make_private_room.
-        /// </summary>
-        internal static string make_private_room_callback {
-            get {
-                return ResourceManager.GetString("make_private_room_callback", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Публичная комната.
         /// </summary>
@@ -375,15 +222,6 @@ namespace MafiaTelegramBot {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to make_public_room.
-        /// </summary>
-        internal static string make_public_room_callback {
-            get {
-                return ResourceManager.GetString("make_public_room_callback", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Максимальное кол-во игроков.
         /// </summary>
@@ -402,15 +240,6 @@ namespace MafiaTelegramBot {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to my_roles.
-        /// </summary>
-        internal static string my_roles_callback {
-            get {
-                return ResourceManager.GetString("my_roles_callback", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Имя было обновлено на.
         /// </summary>
@@ -439,7 +268,16 @@ namespace MafiaTelegramBot {
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Открытых публичных комнат нет.
+        ///   Looks up a localized string similar to Сначала покиньте комнату.
+        /// </summary>
+        internal static string prefer_leave_from_room {
+            get {
+                return ResourceManager.GetString("prefer_leave_from_room", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Нет свободных публичных комнат.
         /// </summary>
         internal static string public_rooms_are_not_exist {
             get {
@@ -456,6 +294,15 @@ namespace MafiaTelegramBot {
             }
         }
         
+        /// <summary>
+        ///   Looks up a localized string similar to Комната не существует.
+        /// </summary>
+        internal static string room_does_not_exists {
+            get {
+                return ResourceManager.GetString("room_does_not_exists", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   Looks up a localized string similar to Комната заполнена.
         /// </summary>
@@ -475,7 +322,7 @@ namespace MafiaTelegramBot {
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Комнаты .
+        ///   Looks up a localized string similar to Комнаты.
         /// </summary>
         internal static string rooms {
             get {
@@ -501,15 +348,6 @@ namespace MafiaTelegramBot {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to settings.
-        /// </summary>
-        internal static string settings_callback {
-            get {
-                return ResourceManager.GetString("settings_callback", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Задайте настройки комнаты.
         /// </summary>
@@ -519,24 +357,6 @@ namespace MafiaTelegramBot {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to settings_room.
-        /// </summary>
-        internal static string settings_room_callback {
-            get {
-                return ResourceManager.GetString("settings_room_callback", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Настройки комнаты.
-        /// </summary>
-        internal static string settings_to_room {
-            get {
-                return ResourceManager.GetString("settings_to_room", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Магазин.
         /// </summary>
@@ -546,24 +366,6 @@ namespace MafiaTelegramBot {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to shop.
-        /// </summary>
-        internal static string shop_callback {
-            get {
-                return ResourceManager.GetString("shop_callback", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Показать профиль.
-        /// </summary>
-        internal static string show_profile {
-            get {
-                return ResourceManager.GetString("show_profile", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Стандартный.
         /// </summary>
@@ -573,15 +375,6 @@ namespace MafiaTelegramBot {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to standart.
-        /// </summary>
-        internal static string standart_callback {
-            get {
-                return ResourceManager.GetString("standart_callback", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Что вы хотите сделать?.
         /// </summary>

+ 7 - 76
MafiaTelegramBot/Resources/strings.resx

@@ -18,15 +18,6 @@
     <resheader name="writer">
         <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
     </resheader>
-    <data name="create_game" xml:space="preserve">
-        <value>Создать игру</value>
-    </data>
-    <data name="connect_game" xml:space="preserve">
-        <value>Присоединиться к игре</value>
-    </data>
-    <data name="show_profile" xml:space="preserve">
-        <value>Показать профиль</value>
-    </data>
     <data name="start_message" xml:space="preserve">
         <value>Что вы хотите сделать?</value>
     </data>
@@ -51,36 +42,18 @@
     <data name="settings" xml:space="preserve">
         <value>Настройки</value>
     </data>
-    <data name="my_roles_callback" xml:space="preserve">
-        <value>my_roles</value>
-    </data>
-    <data name="settings_callback" xml:space="preserve">
-        <value>settings</value>
-    </data>
-    <data name="shop_callback" xml:space="preserve">
-        <value>shop</value>
-    </data>
     <data name="make_public_room" xml:space="preserve">
         <value>Публичная комната</value>
     </data>
-    <data name="make_public_room_callback" xml:space="preserve">
-        <value>make_public_room</value>
-    </data>
     <data name="make_private_room" xml:space="preserve">
         <value>Приватная комната</value>
     </data>
-    <data name="make_private_room_callback" xml:space="preserve">
-        <value>make_private_room</value>
-    </data>
     <data name="your_name" xml:space="preserve">
         <value>Ваше имя:</value>
     </data>
     <data name="change_name" xml:space="preserve">
         <value>Сменить имя</value>
     </data>
-    <data name="change_name_callback" xml:space="preserve">
-        <value>change_name</value>
-    </data>
     <data name="enter_your_name" xml:space="preserve">
         <value>Введите ваше имя</value>
     </data>
@@ -120,15 +93,6 @@
     <data name="user_already_playing" xml:space="preserve">
         <value>Вы уже находитесь в игре</value>
     </data>
-    <data name="settings_room_callback" xml:space="preserve">
-        <value>settings_room</value>
-    </data>
-    <data name="leave" xml:space="preserve">
-        <value>Выйти</value>
-    </data>
-    <data name="leave_callback" xml:space="preserve">
-        <value>leave</value>
-    </data>
     <data name="leave_from_game" xml:space="preserve">
         <value>Вы покинули игру</value>
     </data>
@@ -141,24 +105,12 @@
     <data name="extended" xml:space="preserve">
         <value>Расширенный</value>
     </data>
-    <data name="standart_callback" xml:space="preserve">
-        <value>standart</value>
-    </data>
-    <data name="extended_callback" xml:space="preserve">
-        <value>extended</value>
-    </data>
     <data name="secret_key_is" xml:space="preserve">
         <value>Секретный код для подключения к комнате</value>
     </data>
     <data name="choose_type_room" xml:space="preserve">
         <value>Выберите тип комнаты</value>
     </data>
-    <data name="connect_to_public_room_callback" xml:space="preserve">
-        <value>connect_to_public_room</value>
-    </data>
-    <data name="connect_to_private_room_callback" xml:space="preserve">
-        <value>connect_to_private_room</value>
-    </data>
     <data name="connect_to_private_room" xml:space="preserve">
         <value>Приватная комната</value>
     </data>
@@ -171,9 +123,6 @@
     <data name="room_is_filled" xml:space="preserve">
         <value>Комната заполнена</value>
     </data>
-    <data name="game_is_runing" xml:space="preserve">
-        <value>Игра уже идёт</value>
-    </data>
     <data name="user_already_in_game" xml:space="preserve">
         <value>Вы уже в этой комнате</value>
     </data>
@@ -183,49 +132,31 @@
     <data name="entry_another_user" xml:space="preserve">
         <value>В комнату вошёл</value>
     </data>
-    <data name="look_user_list" xml:space="preserve">
-        <value>Список игроков</value>
-    </data>
-    <data name="look_user_list_callback" xml:space="preserve">
-        <value>look_user_list</value>
-    </data>
     <data name="users_list" xml:space="preserve">
         <value>Участники в комнате</value>
     </data>
     <data name="users_list_empty" xml:space="preserve">
         <value>В комнате нет игроков, кроме вас </value>
     </data>
-    <data name="begin_game" xml:space="preserve">
-        <value>Начать игру</value>
-    </data>
-    <data name="kick_player" xml:space="preserve">
-        <value>Исключить игрока</value>
-    </data>
-    <data name="settings_to_room" xml:space="preserve">
-        <value>Настройки комнаты</value>
-    </data>
     <data name="decrease_number_of_players" xml:space="preserve">
         <value>-</value>
     </data>
-    <data name="decrease_number_of_players_callback" xml:space="preserve">
-        <value>lower_number_of_players</value>
-    </data>
     <data name="increase_number_of_players" xml:space="preserve">
         <value>+</value>
     </data>
-    <data name="increase_number_of_players_callback" xml:space="preserve">
-        <value>increase_number_of_players</value>
-    </data>
     <data name="max_capacity_message" xml:space="preserve">
         <value>Максимальное кол-во игроков</value>
     </data>
-    <data name="connect_to_selected_room_callback" xml:space="preserve">
-        <value>connect_to_selected_room_callback</value>
+    <data name="prefer_leave_from_room" xml:space="preserve">
+        <value>Сначала покиньте комнату</value>
+    </data>
+    <data name="room_does_not_exists" xml:space="preserve">
+        <value>Комната не существует</value>
     </data>
     <data name="public_rooms_are_not_exist" xml:space="preserve">
-        <value>Открытых публичных комнат нет</value>
+        <value>Нет свободных публичных комнат</value>
     </data>
     <data name="rooms" xml:space="preserve">
-        <value>Комнаты </value>
+        <value>Комнаты</value>
     </data>
 </root>

+ 18 - 0
MafiaTelegramBot/Utilities.cs

@@ -0,0 +1,18 @@
+using System.Threading.Tasks;
+
+namespace MafiaTelegramBot
+{
+    public static class Utilities
+    {
+        public static async Task<string> ToMarkdownString(string res)
+        {
+            return await Task.Run(()=> res
+                .Replace(".", "\\.")
+                .Replace("@", "\\@")
+                .Replace("#", "\\#")
+                .Replace("!", "\\!")
+                .Replace("-", "\\-")
+            );
+        }
+    }
+}