コード例 #1
0
        public async Task DefaultRepliesListener()
        {
            //Exit if not reply to bot.
            if (Message.ReplyToMessage?.From != BotContext.BotInfo)
            {
                return;
            }

            if (_gameLogicService.IsStateEmpty(State))
            {
                await SendTextMessageAsync("Hi, i am Quiz bot. Use /help to see my commands.");
            }
            else
            {
                (bool isRight, UserStats userStats) = await _gameLogicService
                                                      .CheckAnswerAndUpdateStats(
                    Message.Text,
                    State,
                    Message.From.Username,
                    Chat.Id.ToString()
                    );

                if (isRight)
                {
                    await SendTextMessageAsync(
                        $"Right!\n@{Message.From.Username} score: {userStats.CorrectAnswersCount}",
                        replyToMessageId : Message.MessageId
                        );
                    await NewQuestion();
                }
                else
                {
                    await SendTextMessageAsync(
                        "Wrong.",
                        replyToMessageId : Message.MessageId
                        );
                }
            }
        }