Beispiel #1
0
  /** {@inheritDoc} */
  @Override
  public void execute(
      final FrameContainer origin, final CommandArguments args, final CommandContext context) {
    final Server server = ((ServerCommandContext) context).getServer();
    final String line = args.getArgumentsAsString();

    server.getParser().sendRawMessage(line);
    sendLine(origin, args.isSilent(), "rawCommand", line);
  }
Beispiel #2
0
 /** {@inheritDoc} */
 @Override
 public int getLineCount(final InputWindow origin, final CommandArguments arguments) {
   if (arguments.getArguments().length >= 2) {
     final String target = arguments.getArguments()[0];
     return origin
         .getContainer()
         .getServer()
         .getNumLines("PRIVMSG " + target + " :" + arguments.getArgumentsAsString(1));
   } else {
     return 1;
   }
 }
Beispiel #3
0
 /** {@inheritDoc} */
 @Override
 public void execute(
     final InputWindow origin,
     final Server server,
     final MessageTarget target,
     final boolean isSilent,
     final CommandArguments args) {
   if (args.getArguments().length == 0) {
     showUsage(origin, isSilent, "me", "<action>");
   } else {
     target.sendAction(args.getArgumentsAsString());
   }
 }
Beispiel #4
0
 @Override
 public void execute(
     final WindowModel origin,
     final Connection connection,
     final String channel,
     final boolean isSilent,
     final CommandArguments args) {
   if (args.getArguments().length < 1) {
     showError(origin, isSilent, "Insufficient arguments: must specify user");
   } else {
     connection.getParser().get().sendInvite(channel, args.getArgumentsAsString());
   }
 }
Beispiel #5
0
  /** {@inheritDoc} */
  @Override
  public void execute(
      final FrameContainer origin, final CommandArguments args, final CommandContext context) {
    final Server server = ((ServerCommandContext) context).getServer();
    if (args.getArguments().length < 2) {
      showUsage(origin, args.isSilent(), "msg", "<target> <message>");
    } else {
      final String target = args.getArguments()[0];
      final String message = args.getArgumentsAsString(1);
      sendLine(origin, args.isSilent(), "selfMessage", target, message);

      // If this is a known server or channel, and this is not a silent
      // invokation, use sendLine, else send it raw to the parser.
      if (!args.isSilent() && server.hasChannel(target)) {
        server.getChannel(target).sendLine(message);
      } else if (!args.isSilent() && server.hasQuery(target)) {
        server.getQuery(target).sendLine(message, target);
      } else {
        final Parser parser = server.getParser();

        if (parser == null) {
          // This can happen if the server gets disconnected after
          // the command manager has checked the @CommandOptions
          // annotation. Yay for concurrency.
          sendLine(
              origin, args.isSilent(), FORMAT_ERROR, "You must be connected to use this command");
        } else {
          parser.sendMessage(target, message);
        }
      }
    }
  }
Beispiel #6
0
 @Override
 public void execute(
     @Nonnull final WindowModel origin,
     final CommandArguments args,
     final CommandContext context) {
   if (args.getArguments().length < 1) {
     showError(origin, args.isSilent(), "Insufficient arguments: must specify user");
   } else {
     final GroupChat groupChat = ((ChannelCommandContext) context).getGroupChat();
     groupChat
         .getConnection()
         .flatMap(Connection::getParser)
         .ifPresent(p -> p.sendInvite(groupChat.getName(), args.getArgumentsAsString()));
   }
 }
Beispiel #7
0
 /** {@inheritDoc} */
 @Override
 public void execute(
     final FrameContainer origin, final CommandArguments args, final CommandContext context) {
   final Server server = ((ServerCommandContext) context).getServer();
   if (args.getArguments().length < 2) {
     showUsage(origin, args.isSilent(), "ctcp", "<target> <type> [arguments]");
   } else {
     server
         .getParser()
         .sendCTCP(args.getArguments()[0], args.getArguments()[1], args.getArgumentsAsString(2));
     sendLine(
         origin,
         args.isSilent(),
         "selfCTCP",
         args.getArguments()[0],
         args.getArgumentsAsString(1));
   }
 }
Beispiel #8
0
  /** {@inheritDoc} */
  @Override
  public ValidationResponse validateArguments(
      final InputWindow origin, final CommandArguments arguments) {
    if (origin.getContainer().getServer() == null
        || origin.getContainer().getServer().getParser() == null) {
      return new ValidationResponse();
    }

    final int length = 2 + arguments.getArgumentsAsString().length();

    if (origin
            .getContainer()
            .getServer()
            .getParser()
            .getMaxLength("PRIVMSG", origin.getContainer().toString())
        <= length) {
      return new ValidationResponse("Too long");
    } else {
      return new ValidationResponse();
    }
  }