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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations