예제 #1
0
        /// <summary>
        /// Gets markup for determination question
        /// </summary>
        /// <param name="gameDate">Date of game</param>
        /// <returns></returns>
        public static InlineKeyboardMarkup GetUserDeterminationMarkup(DateTime gameDate)
        {
            var labels = new[] { Constants.YES_ANSWER, Constants.NO_ANSWER, Constants.MAYBE_ANSWER };
            var values = labels;

            return(GetKeyBoardMarkup(PlayerSetCallback.GetCallbackPrefix(gameDate), labels, values));
        }
예제 #2
0
        public void GetGameStartCallbackText_ReturnsCorrectText()
        {
            var gameDate = new DateTime(2020, 07, 25);
            var text     = PlayerSetCallback.GetCallbackPrefix(gameDate);

            Assert.Equal("PlayersSetDetermination|2020-07-25", text);
        }
        private async Task DetermineIfUserIsReadyToPlayAsync(CallbackQuery callbackQuery)
        {
            var playerSetCallback = new PlayerSetCallback(callbackQuery.Data);

            await ClearInlineKeyboardAsync(callbackQuery.Message.Chat.Id, callbackQuery.Message.MessageId);

            try
            {
                await _client.DeleteMessageWithTokenAsync(callbackQuery.Message.Chat.Id, callbackQuery.Message.MessageId);
            }
            catch (Exception ex)
            {
                _logger.Error(ex, $"Error on deleting message");
            }

            if (IsButtonPressedAfterGame(playerSetCallback.GameDate))
            {
                _logger.Information($"Button pressed after game: now - {DateTime.UtcNow}, game date - {playerSetCallback.GameDate.Date}");
                return;
            }

            var player = await _playerRepository.GetAsync(callbackQuery.From.Id);

            await SheetController.GetInstance().UpdateApproveCellAsync(player.Name, GetApproveCellValue(playerSetCallback.UserAnswer));

            player.IsGoingToPlay            = playerSetCallback.UserAnswer == Constants.YES_ANSWER;
            player.ApprovedPlayersMessageId = await SendApprovedPlayersMessageAsync(callbackQuery.Message.Chat.Id, player);

            await _playerRepository.UpdateAsync(player);
        }
예제 #4
0
        public void GetCallbackGameDate_ReturnsCorrectDate()
        {
            var callBack = new PlayerSetCallback("PlayersSetDetermination|2020-07-25_Да");

            Assert.Equal(new DateTime(2020, 07, 25), callBack.GameDate);
        }