Пример #1
0
        internal void UpdatePoll(HockeyChat chat, int msgid, CallbackQuery e)
        {
            var poll = chat.Polls.FindLast(x => x.MessageId == msgid);

            if (poll == null)
            {
                return;
            }
            _currentPoll = poll;

            var user   = e.From;
            var player = _db.GetPlayerByUserid(user.Id);
            var vote   = new Vote(msgid, user.Id, user.Username, player == null ? user.FirstName : player.Name,
                                  player == null ? user.LastName : player.Surname, e.Data);
            var voteDupl = poll.Votes.FindLast(x => x.TelegramUserId == vote.TelegramUserId);

            if (voteDupl != null)
            {
                if (voteDupl.Data == vote.Data)
                {
                    return;
                }

                voteDupl.Data = vote.Data;
                _db.UpdateVoteData(msgid, vote.TelegramUserId, vote.Data);
            }
            else
            {
                AddVoteToPoll(poll, vote);
            }
        }