Browse Source

Change keyboard type

Tigran 4 years ago
parent
commit
bdd60b17ab

+ 1 - 2
MafiaTelegramBot/MessageController.cs → MafiaTelegramBot/Controllers/MessageController.cs

@@ -1,5 +1,4 @@
 using System;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 using MafiaTelegramBot.Models.Commands;
@@ -9,7 +8,7 @@ using Telegram.Bot.Exceptions;
 using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
 
-namespace MafiaTelegramBot
+namespace MafiaTelegramBot.Controllers
 {
     public static class MessageController //: ApiController
     {

+ 2 - 6
MafiaTelegramBot/MafiaTelegramBot.csproj

@@ -12,18 +12,14 @@
     </ItemGroup>
 
     <ItemGroup>
-      <Folder Include="Controllers" />
-    </ItemGroup>
-
-    <ItemGroup>
-      <EmbeddedResource Update="strings.resx">
+      <EmbeddedResource Update="Resources\strings.resx">
         <Generator>ResXFileCodeGenerator</Generator>
         <LastGenOutput>strings.Designer.cs</LastGenOutput>
       </EmbeddedResource>
     </ItemGroup>
 
     <ItemGroup>
-      <Compile Update="strings.Designer.cs">
+      <Compile Update="Resources\strings.Designer.cs">
         <DesignTime>True</DesignTime>
         <AutoGen>True</AutoGen>
         <DependentUpon>strings.resx</DependentUpon>

+ 2 - 0
MafiaTelegramBot/MainClass.cs

@@ -1,5 +1,7 @@
 using System;
 using System.Threading;
+using MafiaTelegramBot.Controllers;
+using MafiaTelegramBot.Models;
 using Telegram.Bot;
 using Telegram.Bot.Extensions.Polling;
 

+ 6 - 2
MafiaTelegramBot/Bot.cs → MafiaTelegramBot/Models/Bot.cs

@@ -1,9 +1,10 @@
 using System.Collections.Generic;
 using MafiaTelegramBot.Models.Commands;
 using MafiaTelegramBot.Models.Queries;
+using MafiaTelegramBot.Resources;
 using Telegram.Bot;
 
-namespace MafiaTelegramBot
+namespace MafiaTelegramBot.Models
 {
     public static class Bot
     {
@@ -33,7 +34,10 @@ namespace MafiaTelegramBot
             //TODO fill commands array
             _commandsList = new List<Command>
             {
-                new SendKeyboard()
+                new StartCommand(),
+                new CreateGameCommand(),
+                new ConnectGameCommand(),
+                new ShowProfileCommand()
             };
         }
         

+ 1 - 0
MafiaTelegramBot/Models/Commands/Command.cs

@@ -1,5 +1,6 @@
 using System.Linq;
 using System.Threading.Tasks;
+using MafiaTelegramBot.Resources;
 using Telegram.Bot;
 using Telegram.Bot.Types;
 

+ 17 - 0
MafiaTelegramBot/Models/Commands/ConnectGameCommand.cs

@@ -0,0 +1,17 @@
+using System.Threading.Tasks;
+using Telegram.Bot;
+using Telegram.Bot.Types;
+using Telegram.Bot.Types.Enums;
+
+namespace MafiaTelegramBot.Models.Commands
+{
+    public class ConnectGameCommand : Command
+    {
+        protected override string Name => strings.connect_game;
+        protected override async Task<Message> Execute(long chatId, TelegramBotClient client)
+        {
+            await Bot.Get().SendChatActionAsync(chatId, ChatAction.Typing);
+            return await Bot.Get().SendTextMessageAsync(chatId, strings.connect_game);
+        }
+    }
+}

+ 17 - 0
MafiaTelegramBot/Models/Commands/CreateGameCommand.cs

@@ -0,0 +1,17 @@
+using System.Threading.Tasks;
+using Telegram.Bot;
+using Telegram.Bot.Types;
+using Telegram.Bot.Types.Enums;
+
+namespace MafiaTelegramBot.Models.Commands
+{
+    public class CreateGameCommand : Command
+    {
+        protected override string Name => strings.create_game;
+        protected override async Task<Message> Execute(long chatId, TelegramBotClient client)
+        {
+            await Bot.Get().SendChatActionAsync(chatId, ChatAction.Typing);
+            return await Bot.Get().SendTextMessageAsync(chatId, strings.create_game);
+        }
+    }
+}

+ 0 - 34
MafiaTelegramBot/Models/Commands/SendKeyboard.cs

@@ -1,34 +0,0 @@
-using System.Threading.Tasks;
-using Telegram.Bot;
-using Telegram.Bot.Types;
-using Telegram.Bot.Types.Enums;
-using Telegram.Bot.Types.ReplyMarkups;
-
-namespace MafiaTelegramBot.Models.Commands
-{
-    public class SendKeyboard : Command
-    {
-        protected override string Name => "/start";
-
-        protected override async Task<Message> Execute(long chatId, TelegramBotClient client)
-        {
-            await Bot.Get().SendChatActionAsync(chatId, ChatAction.Typing);
-            InlineKeyboardMarkup inlineKeyboard = new (new[]
-            {
-                new[]
-                {
-                    InlineKeyboardButton.WithCallbackData(strings.create_game, "create_game")
-                },
-                new[]
-                {
-                    InlineKeyboardButton.WithCallbackData(strings.connect_game, "connect_game")
-                },
-                new[]
-                {
-                    InlineKeyboardButton.WithCallbackData(strings.show_profile, "show_profile")
-                }
-            });
-            return await Bot.Get().SendTextMessageAsync(chatId, strings.start_message, replyMarkup: inlineKeyboard);
-        }
-    }
-}

+ 17 - 0
MafiaTelegramBot/Models/Commands/ShowProfileCommand.cs

@@ -0,0 +1,17 @@
+using System.Threading.Tasks;
+using Telegram.Bot;
+using Telegram.Bot.Types;
+using Telegram.Bot.Types.Enums;
+
+namespace MafiaTelegramBot.Models.Commands
+{
+    public class ShowProfileCommand : Command
+    {
+        protected override string Name => strings.show_profile;
+        protected override async Task<Message> Execute(long chatId, TelegramBotClient client)
+        {
+            await Bot.Get().SendChatActionAsync(chatId, ChatAction.Typing);
+            return await Bot.Get().SendTextMessageAsync(chatId, strings.show_profile);
+        }
+    }
+}

+ 28 - 0
MafiaTelegramBot/Models/Commands/StartCommand.cs

@@ -0,0 +1,28 @@
+using System.Threading.Tasks;
+using Telegram.Bot;
+using Telegram.Bot.Types;
+using Telegram.Bot.Types.Enums;
+using Telegram.Bot.Types.ReplyMarkups;
+
+namespace MafiaTelegramBot.Models.Commands
+{
+    public class StartCommand : Command
+    {
+        protected override string Name => "/start";
+
+        protected override async Task<Message> Execute(long chatId, TelegramBotClient client)
+        {
+            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
+            );
+            return await Bot.Get().SendTextMessageAsync(chatId, strings.start_message, replyMarkup: keyboard);
+        }
+    }
+}

+ 0 - 0
MafiaTelegramBot/Models/Queries/ConnectGame.cs → MafiaTelegramBot/Models/Inlines/ConnectGame.cs


+ 0 - 0
MafiaTelegramBot/Models/Queries/CreateGame.cs → MafiaTelegramBot/Models/Inlines/CreateGame.cs


+ 0 - 0
MafiaTelegramBot/Models/Queries/Query.cs → MafiaTelegramBot/Models/Inlines/Query.cs


+ 0 - 0
MafiaTelegramBot/Models/Queries/ShowProfile.cs → MafiaTelegramBot/Models/Inlines/ShowProfile.cs


+ 1 - 1
MafiaTelegramBot/AppSettings.cs → MafiaTelegramBot/Resources/AppSettings.cs

@@ -1,4 +1,4 @@
-namespace MafiaTelegramBot
+namespace MafiaTelegramBot.Resources
 {
     public static class AppSettings
     {

+ 1 - 1
MafiaTelegramBot/strings.Designer.cs → MafiaTelegramBot/Resources/strings.Designer.cs

@@ -39,7 +39,7 @@ namespace MafiaTelegramBot {
         internal static global::System.Resources.ResourceManager ResourceManager {
             get {
                 if (object.ReferenceEquals(resourceMan, null)) {
-                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MafiaTelegramBot.strings", typeof(strings).Assembly);
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MafiaTelegramBot.Resources.strings", typeof(strings).Assembly);
                     resourceMan = temp;
                 }
                 return resourceMan;

+ 0 - 0
MafiaTelegramBot/strings.resx → MafiaTelegramBot/Resources/strings.resx