Search in sources :

Example 1 with ReplaceObject

use of com.github.vaerys.objects.ReplaceObject in project DiscordSailv2 by Vaerys-Dawn.

the class TagRegex method execute.

@Override
public String execute(String from, CommandObject command, String args, List<ReplaceObject> toReplace) {
    List<String> splitArgs = getSplit(from);
    String test = "Testing.";
    try {
        test.replaceAll(splitArgs.get(0), test);
    } catch (PatternSyntaxException e) {
        from = replaceFirstTag(from, error);
        return from;
    }
    from = removeFirstTag(from);
    toReplace.add(new ReplaceObject(splitArgs.get(0), splitArgs.get(1)));
    return from;
}
Also used : ReplaceObject(com.github.vaerys.objects.ReplaceObject) TagReplaceObject(com.github.vaerys.templates.TagReplaceObject) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Example 2 with ReplaceObject

use of com.github.vaerys.objects.ReplaceObject in project DiscordSailv2 by Vaerys-Dawn.

the class TagReplace method execute.

@Override
public String execute(String from, CommandObject command, String args, List<ReplaceObject> toReplace) {
    List<String> splitArgs = getSplit(from);
    from = removeFirstTag(from);
    toReplace.add(new ReplaceObject(splitArgs.get(0), splitArgs.get(1)));
    return from;
}
Also used : ReplaceObject(com.github.vaerys.objects.ReplaceObject) TagReplaceObject(com.github.vaerys.templates.TagReplaceObject)

Example 3 with ReplaceObject

use of com.github.vaerys.objects.ReplaceObject in project DiscordSailv2 by Vaerys-Dawn.

the class TagIfArgsEmptyReplace method execute.

@Override
public String execute(String from, CommandObject command, String args, List<ReplaceObject> toReplace) {
    List<String> splitString = getSplit(from);
    from = removeFirstTag(from);
    if (args == null || args.isEmpty()) {
        toReplace.add(new ReplaceObject(splitString.get(0), splitString.get(1)));
    } else {
        toReplace.add(new ReplaceObject(splitString.get(0), splitString.get(2)));
    }
    return from;
}
Also used : ReplaceObject(com.github.vaerys.objects.ReplaceObject) TagReplaceObject(com.github.vaerys.templates.TagReplaceObject)

Example 4 with ReplaceObject

use of com.github.vaerys.objects.ReplaceObject in project DiscordSailv2 by Vaerys-Dawn.

the class TagIfChannelReplace method execute.

@Override
public String execute(String from, CommandObject command, String args, List<ReplaceObject> toReplace) {
    List<String> splitString = getSplit(from);
    from = removeFirstTag(from);
    long id;
    if (!Pattern.compile("<#[0-9]*>").matcher(splitString.get(0)).matches()) {
        return replaceFirstTag(from, error);
    } else {
        try {
            id = Long.parseUnsignedLong(StringUtils.substringBetween(splitString.get(0), "<#", ">"));
        } catch (NumberFormatException e) {
            return replaceFirstTag(from, error);
        }
        if (id == command.channel.longID) {
            toReplace.add(new ReplaceObject(splitString.get(1), splitString.get(2)));
        } else {
            toReplace.add(new ReplaceObject(splitString.get(1), splitString.get(3)));
        }
    }
    return from;
}
Also used : ReplaceObject(com.github.vaerys.objects.ReplaceObject) TagReplaceObject(com.github.vaerys.templates.TagReplaceObject)

Example 5 with ReplaceObject

use of com.github.vaerys.objects.ReplaceObject in project DiscordSailv2 by Vaerys-Dawn.

the class TagIfNameReplace method execute.

@Override
public String execute(String from, CommandObject command, String args, List<ReplaceObject> toReplace) {
    List<String> splitString = getSplit(from);
    from = removeFirstTag(from);
    String displayName = command.user.displayName;
    String userName = command.user.name;
    if (StringUtils.containsIgnoreCase(displayName, splitString.get(0)) || StringUtils.containsIgnoreCase(userName, splitString.get(0))) {
        toReplace.add(new ReplaceObject(splitString.get(1), splitString.get(2)));
    } else {
        toReplace.add(new ReplaceObject(splitString.get(1), splitString.get(3)));
    }
    return from;
}
Also used : ReplaceObject(com.github.vaerys.objects.ReplaceObject) TagReplaceObject(com.github.vaerys.templates.TagReplaceObject)

Aggregations

ReplaceObject (com.github.vaerys.objects.ReplaceObject)8 TagReplaceObject (com.github.vaerys.templates.TagReplaceObject)8 Random (java.util.Random)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 IRole (sx.blah.discord.handle.obj.IRole)1