Exemple #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));
        }
Exemple #2
0
        //[ProducesResponseType(typeof(IActionResult), (int)HttpStatusCode.OK)]
        public async Task <IActionResult> AddCounter(CounterDetails counter)
        {
            var result = await _counterService.AddCounter(counter);

            if (result)
            {
                return(Ok(true));
            }
            return(BadRequest(MessageConstants.SomethingWentWrong));
        }
Exemple #3
0
 public async Task <CounterInfo> CreateCounter()
 {
     return(await _counterService.AddCounter(_securityService.GetUserID(HttpContext)));
 }