Exemplo n.º 1
0
        public void AddVote(Voting voting, Tuple <string, string> vote)
        {
            if (!Votings.ContainsKey(voting.ActionName.ToLower()))
            {
                return;
            }

            voting.AddVote(vote);
        }
Exemplo n.º 2
0
        public void EditVotetimeCommand(string action, int milliseconds)
        {
            if (!Votings.ContainsKey(action))
            {
                return;
            }

            Voting voting = Votings[action];

            voting.Milliseconds = milliseconds;
            Client.SendMessage(Channel, string.Format("Votetime for action '{0}' set to {1} sec", action, milliseconds / 1000));
        }
Exemplo n.º 3
0
        public void VoteCommand(string user, string action, string choice)
        {
            if (!Votings.ContainsKey(action))
            {
                return;
            }

            Voting voting = Votings[action];

            if (!voting.IsActive)
            {
                DoVoting(voting);
            }

            AddVote(voting, new Tuple <string, string>(user, choice));
        }
Exemplo n.º 4
0
        public void AddVoting(string action, IEnumerable <string> choices, int milliseconds = 0, Action <OBSWebsocket, IEnumerable <Tuple <string, int> > > afterVote = null)
        {
            string actionLower = action.ToLower();

            if (Votings.ContainsKey(actionLower))
            {
                Client.SendMessage(Channel, string.Format("Voting '{0}' exists already!", action));
                return;
            }

            if (milliseconds == 0)
            {
                milliseconds = DefaultMilliseconds;
            }
            Voting voting = new Voting(action, choices, milliseconds, afterVote);

            Votings.Add(action, voting);
        }
Exemplo n.º 5
0
        public async void DoVoting(Voting voting)
        {
            int seconds = voting.Milliseconds / 1000;

            Client.SendMessage(Channel, string.Format("Voting '{0}' has started! Voting runs {1} seconds.", voting.ActionName, seconds));

            voting.IsActive = true;
            await Task.Delay(voting.Milliseconds);

            voting.IsActive = false;

            Client.SendMessage(Channel, string.Format("Voting '{0}' has ended!", voting.ActionName));

            var result = voting.GetResult();

            ShowVotingResult(result);

            voting.AfterVote?.Invoke(Obs, result);
            voting.ResetVotes();
        }
Exemplo n.º 6
0
        public void VoteInfoCommand(string action)
        {
            Voting vote = GetVotingInfo(action);

            Client.SendMessage(Channel, string.Format("Action: {0}, Choices: {1}, Vote time: {2} sec", vote.ActionName, string.Join(" | ", vote.Choices.Values), vote.Milliseconds / 1000));
        }