示例#1
0
        private void ProcessMessage(BotEventArgs e)
        {
            Result <CommandArgumentContainer> commandResult = _commandParser.ParseCommand(e);

            if (commandResult.IsFailed)
            {
                return;
            }

            if (!commandResult.Value.EnsureStartWithPrefix(_prefix))
            {
                return;
            }

            commandResult = _commandHandler.IsCorrectArgumentCount(commandResult.Value.ApplySettings(_prefix));
            if (commandResult.IsFailed)
            {
                HandlerError(commandResult, e);
                return;
            }

            commandResult = _commandHandler.IsCommandCanBeExecuted(commandResult.Value);
            if (commandResult.IsFailed)
            {
                HandlerError(commandResult, e);
                return;
            }

            Result <IBotMessage> executionResult = _commandHandler.ExecuteCommand(commandResult.Value);

            if (executionResult.IsFailed)
            {
                HandlerError(commandResult, e);
                return;
            }

            IBotMessage message = executionResult.Value;
            SenderInfo  sender  = commandResult.Value.Sender;

            //_apiProvider.WriteMessage(new BotEventArgs(executionResult.Value, commandResult.Value));
            message.Send(_apiProvider, sender);
        }
示例#2
0
 public BotEventArgs(IBotMessage message, SenderInfo sender)
 {
     Message = message;
     Sender  = sender;
 }