Browse Source

Refactor code

Tigran 4 years ago
parent
commit
0f2f1b29c6

+ 7 - 1
MafiaTelegramBot/Controllers/MessageController.cs

@@ -45,7 +45,13 @@ namespace MafiaTelegramBot.Controllers
             }
             catch (NullReferenceException)
             {
-                Console.WriteLine("Command not found");
+                var command = update.Type switch
+                {
+                    UpdateType.Message => update.Message.Text,
+                    UpdateType.CallbackQuery => update.CallbackQuery.Data,
+                    _ => "unknown"
+                };
+                Console.WriteLine($"Command \"{command}\" not found");
             }
             catch (Exception exception)
             {

+ 1 - 1
MafiaTelegramBot/Models/UpdateModel.cs

@@ -11,7 +11,7 @@ namespace MafiaTelegramBot.Models
         
         public abstract Task<Message> Execute(Update update);
 
-        private bool Contains(string command)
+        protected bool Contains(string command)
         {
             return command.Contains(Name);
         }