Пример #1
0
        public override string TryToExecute(CommandReceivedEventArgs eventArgs)
        {
            if (!_votingSystem.IsVoteActive)
            {
                return("There's no vote right now...");
            }

            if (eventArgs.ChatUser.IsInThisRoleOrHigher(UserRole.Mod))
            {
                return(_votingSystem.EndVoting());
            }

            return("You don't have permission to end the voting...");
        }
Пример #2
0
        private string SetVoteToEnd(IChatClient chatClient, CommandReceivedEventArgs eventArgs)
        {
            if (!_votingSystem.IsVoteActive)
            {
                return("There's no vote right now...");
            }

            if (!eventArgs.ChatUser.IsInThisRoleOrHigher(UserRole.Mod))
            {
                return("You don't have permission to end the voting...");
            }

            string delayArg = eventArgs.Arguments.ElementAtOrDefault(1);

            if (string.IsNullOrWhiteSpace(delayArg))
            {
                return(_votingSystem.EndVoting());
            }

            int secondsDelay = GetSecondsDelay(delayArg);

            if (secondsDelay <= 0)
            {
                return("Invalid delay specified");
            }

            if (_endVoteCallback == null)
            {
                _endVoteCallback = new DelayableCallbackAction(secondsDelay, () => chatClient.SendMessage(_votingSystem.EndVoting()));
                _automatedActionSystem.AddAction(_endVoteCallback);
                return($"Vote will end in {secondsDelay} seconds.");
            }

            _endVoteCallback.SetTimeout(secondsDelay);
            return($"Vote will instead end in {secondsDelay} seconds.");
        }