|
@@ -1,28 +1,40 @@
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using MafiaTelegramBot.Controllers;
|
|
using MafiaTelegramBot.Controllers;
|
|
using MafiaTelegramBot.DataBase;
|
|
using MafiaTelegramBot.DataBase;
|
|
|
|
+using MafiaTelegramBot.Models.Inlines;
|
|
using MafiaTelegramBot.Resources;
|
|
using MafiaTelegramBot.Resources;
|
|
using Telegram.Bot.Types;
|
|
using Telegram.Bot.Types;
|
|
using Telegram.Bot.Types.Enums;
|
|
using Telegram.Bot.Types.Enums;
|
|
|
|
+using Telegram.Bot.Types.ReplyMarkups;
|
|
|
|
|
|
-namespace MafiaTelegramBot.Models.Inlines
|
|
|
|
|
|
+namespace MafiaTelegramBot.Models.Commands
|
|
{
|
|
{
|
|
- public class LeaveQuery : Query
|
|
|
|
|
|
+ public class LeaveCommand : Command
|
|
{
|
|
{
|
|
- protected override string Name => strings.leave_callback;
|
|
|
|
|
|
+ protected override string Name => strings.leave;
|
|
public override async Task<Message> Execute(Update update)
|
|
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;
|
|
|
|
|
|
+ var chatId = update.Message.Chat.Id;
|
|
await Bot.Get().SendChatActionAsync(chatId, ChatAction.Typing);
|
|
await Bot.Get().SendChatActionAsync(chatId, ChatAction.Typing);
|
|
- var data = update.CallbackQuery.Data;
|
|
|
|
- var userId = long.Parse(data.Split('|')[1]);
|
|
|
|
|
|
+
|
|
|
|
+ var userId = update.Message.From.Id;
|
|
var user = await UserDao.GetUserById(userId);
|
|
var user = await UserDao.GetUserById(userId);
|
|
var game = user!.GetCurrentGame();
|
|
var game = user!.GetCurrentGame();
|
|
var result = await RoomController.LeaveFromGame(user);
|
|
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
|
|
return result switch
|
|
{
|
|
{
|
|
- Constants.CODE_OK => await Bot.SendWithMarkdown2(chatId, $"{strings.leave_from_game} _*{game}*_"),
|
|
|
|
|
|
+ Constants.CODE_OK => await Bot.SendWithMarkdown2(chatId, $"{strings.leave_from_game} _*{game}*_", keyboard),
|
|
Constants.USER_NOT_IN_GAME => await Bot.SendWithMarkdown2(chatId, strings.not_in_game),
|
|
Constants.USER_NOT_IN_GAME => await Bot.SendWithMarkdown2(chatId, strings.not_in_game),
|
|
_ => await Bot.SendWithMarkdown2(chatId, strings.unexpected_error)
|
|
_ => await Bot.SendWithMarkdown2(chatId, strings.unexpected_error)
|
|
};
|
|
};
|