示例#1
0
        public async Task ProcessAsync(Update update)
        {
            _logger.LogInformation($"[ {DateTime.Now.ToLocalTime().ToString(CultureInfo.InvariantCulture)} ] Processing sleep callback... {update.CallbackQuery.From.Username}, chatId: {update.CallbackQuery.Message.Chat.Id.ToString()}");

            Poll     poll            = PollsHelper.GetPoll(update.CallbackQuery.Message.Chat.Id);
            bool     userListUpdated = poll.AddSleepVote(update.CallbackQuery.From);
            PollView pollView        = poll.AsView();

            if (userListUpdated)
            {
                await PollVoteThrottle.Acquire();

                await _botService.Client.EditMessageTextAsync(
                    chatId : poll.ChatId,
                    messageId : poll.MessageId,
                    text : pollView.Text,
                    parseMode : ParseMode.Html,
                    replyMarkup : pollView.ReplyMarkup);
            }

            await _botService.Client.AnswerCallbackQueryAsync(
                callbackQueryId : update.CallbackQuery.Id,
                text : pollView.SleepCallbackQueryAnswer);
        }
示例#2
0
 public PollView(Poll poll)
 {
     _poll       = poll;
     Text        = CreateText();
     ReplyMarkup = CreateReplyMarkup();
 }