Tigran пре 4 година
родитељ
комит
4d91c04e4e
1 измењених фајлова са 6 додато и 3 уклоњено
  1. 6 3
      MafiaTelegramBot/Models/Commands/Command.cs

+ 6 - 3
MafiaTelegramBot/Models/Commands/Command.cs

@@ -27,8 +27,13 @@ namespace MafiaTelegramBot.Models.Commands
         public static async Task<Message> Update(Update update)
         {
             var chatId = update.Message.Chat.Id;
-            var userId = update.Message.From.Id;
             await Bot.Get().SendChatActionAsync(chatId, ChatAction.Typing);
+            var userId = update.Message.From.Id;
+            var commands = Bot.Commands;
+            var message = update.Message.Text;
+            var startCommand = new StartCommand();
+            //TODO refactor later
+            if (message.Contains(startCommand.Name)) return await ((Command?) startCommand.Clone(chatId, userId))!.Execute(update);
             var user = await UserDao.GetPlayerById(userId);
             if (user.IsPlaying)
             {
@@ -36,8 +41,6 @@ namespace MafiaTelegramBot.Models.Commands
                 var room = RoomController.GetRoom(roomKey);
                 return await room.Handler.Handle(update);
             }
-            var commands = Bot.Commands;
-            var message = update.Message.Text;
             var command = FirstOrDefault(commands, message);
             if(command != null) return await ((Command?) command.Clone(chatId, userId))!.Execute(update);
             if (Bot.UsersThatChangesNickname.Remove(userId))