Dbot.Processor.Commander.Run C# (CSharp) Method

Run() public method

public Run ( ) : Message
return Message
        public Message Run()
        {
            //todo could clean this up a bit. Add _commandDictionary to some Datastore and add CustomCommands to it instead of this two tiered logic.
              var customCommand = Datastore.CustomCommands.FirstOrDefault(y => _text.StartsWith(y.Key)).Value;
              if (customCommand != null) {
            if (!_message.IsMod)
              _messageProcessor.NextCommandTime = DateTime.UtcNow + Settings.UserCommandInterval;
            return new ModPublicMessage(customCommand);
              }
              var command = _commandDictionary.FirstOrDefault(y => y.Key.Any(x => _text.StartsWith(x))).Value;
              if (command != null) {
            if (!_message.IsMod)
              _messageProcessor.NextCommandTime = DateTime.UtcNow + Settings.UserCommandInterval;
            var returnMessage = command.Invoke();
            var newLineCount = returnMessage.Count(x => x == '\n');
            if (newLineCount >= 3) {
              _messageProcessor.NextCommandTime = DateTime.UtcNow + Settings.UserCommandInterval.Multiply(newLineCount - 1);
            }
            return new ModPublicMessage(returnMessage);
              }
              return null;
        }