|
@@ -12,13 +12,15 @@ namespace MafiaTelegramBot.Models.Commands
|
|
|
protected override string Name => keyboard.begin_game;
|
|
|
protected override async Task<Message> Execute(Update update)
|
|
|
{
|
|
|
- var owner = await UserDao.GetPlayerById(UserId);
|
|
|
- var roomKey = RoomEncrypter.GetCode(owner.GetRoomName());
|
|
|
+ var player = await UserDao.GetPlayerById(UserId);
|
|
|
+ var roomKey = RoomEncrypter.GetCode(player.GetRoomName());
|
|
|
var room = RoomController.GetRoom(roomKey);
|
|
|
if(room == null)
|
|
|
return await Bot.SendWithMarkdown2(ChatId, strings.room_does_not_exists);
|
|
|
- if (room.IsExtended) return await Bot.SendWithMarkdown2(owner.ChatId, strings.continue_question, Keyboard.StartExtendedRoomKeyboard(UserId));
|
|
|
- var result = await Bot.SendWithMarkdown2(owner.ChatId, strings.game_process_started);
|
|
|
+ if (!player.Equals(room.Owner))
|
|
|
+ return await Bot.SendWithMarkdown2(ChatId, $"{strings.command_not_found} _*({update.Message.Text})*_");
|
|
|
+ if (room.IsExtended) return await Bot.SendWithMarkdown2(player.ChatId, strings.continue_question, Keyboard.StartExtendedRoomKeyboard(UserId));
|
|
|
+ var result = await Bot.SendWithMarkdown2(player.ChatId, strings.game_process_started);
|
|
|
var resultCode = await room.Prepare();
|
|
|
if (resultCode != ResultCode.CodeOk) return await Utilities.GetResultCodeMessage(resultCode, ChatId);
|
|
|
room.Start();
|