Exemplo n.º 1
0
        private static void RestorePollFromDb(int messageId, HockeyChat chat)
        {
            var poll = _db.GetPollByMessageId(messageId);

            if (poll == null)
            {
                return;
            }

            chat.Polls.Add(poll);

            poll.Votes = _db.GetVotesByMessageId(messageId);
            Console.WriteLine("Poll restored from DB: " + poll.Question);
        }
Exemplo n.º 2
0
        private async void AddPoll(HockeyChat chat, string arg)
        {
            chat.VoteMode = false;
            var btnYes = new InlineKeyboardButton
            {
                Text         = "Да",
                CallbackData = "Да"
            };
            var btnNo = new InlineKeyboardButton
            {
                Text         = "Не",
                CallbackData = "Не"
            };
            var btnShow = new InlineKeyboardButton
            {
                Text         = "Показать результаты",
                CallbackData = "Show"
            };
            var keyboard = new InlineKeyboardMarkup(new[] { new [] { btnYes, btnNo }, new[] { btnShow } });

            var msg = await _bot.SendTextMessageAsync(chat.Id, $"{arg}", replyMarkup : keyboard);

            var v    = new List <Vote>();
            var poll = new HockeyPoll()
            {
                MessageId = msg.MessageId, Votes = v, Question = arg
            };

            _currentPoll = poll;

            _db.AddPoll(poll);
            var addedPoll = _db.GetPollByMessageId(poll.MessageId);

            poll.Id = addedPoll.Id;

            chat.Polls.Add(poll);
        }