예제 #1
0
        public override Task <bool> Invoke(ChatMessage message)
        {
            // Temporary fix to restrict command
            // TODO: Create proper permissions system
            if (!(message.IsModerator || message.IsBroadcaster))
            {
                return(Task.FromResult(false));
            }

            var counter = _counterService.GetCounter(_counterKey) ?? _counterService.AddCounter(_counterKey);

            switch (_arithmetic)
            {
            case Arithmetic.Addition:
                _counterService.AddCount(counter);
                break;

            case Arithmetic.Subtraction:
                _counterService.RemoveCount(counter);
                break;

            default:
                _twitchClient.SendMessage(message.Channel, "You must specify addition (+) or subtraction (-).");
                break;
            }

            _twitchClient.SendMessage(message.Channel,
                                      $"{counter.Name} adjusted. Current {counter.Name}: {counter.Count}");

            return(Task.FromResult(true));
        }