Search in sources :

Example 1 with TagObject

use of com.github.vaerys.templates.TagObject in project DiscordSailv2 by Vaerys-Dawn.

the class TagList method validate.

private static void validate(List<TagObject> tags) {
    for (TagObject c : tags) {
        logger.trace("Validating Tag: " + c.getClass().getName());
        String errorReport = c.validate();
        Globals.addToErrorStack(errorReport);
    }
    sort(tags);
}
Also used : TagObject(com.github.vaerys.templates.TagObject)

Example 2 with TagObject

use of com.github.vaerys.templates.TagObject in project DiscordSailv2 by Vaerys-Dawn.

the class RandomCC method execute.

@Override
public String execute(String args, CommandObject command) {
    Random random = new Random();
    int counter = 0;
    List<CCommandObject> commands = command.guild.customCommands.getCommandList();
    CCommandObject randCC = commands.get(random.nextInt(commands.size()));
    while (!command.channel.settings.contains(ChannelSetting.SHITPOST) && randCC.isShitPost() && command.guild.config.shitPostFiltering) {
        if (counter > 25) {
            return "> Your server has way to many shitpost commands, I couldn't find you a normal one.";
        }
        randCC = commands.get(random.nextInt(commands.size()));
        try {
            Thread.sleep(50);
        } catch (InterruptedException e) {
            Utility.sendStack(e);
        }
        counter++;
    }
    String response = randCC.getContents(true);
    for (TagObject t : TagList.getType(TagType.CC)) {
        if (t.name.equals(new TagEmbedImage(0).name)) {
            response = t.handleTag(response + "\n`" + command.guild.config.getPrefixCC() + randCC.getName() + "`", command, args);
        } else {
            response = t.handleTag(response, command, args);
        }
    }
    return response;
}
Also used : CCommandObject(com.github.vaerys.objects.CCommandObject) Random(java.util.Random) TagObject(com.github.vaerys.templates.TagObject) TagEmbedImage(com.github.vaerys.tags.cctags.TagEmbedImage)

Example 3 with TagObject

use of com.github.vaerys.templates.TagObject in project DiscordSailv2 by Vaerys-Dawn.

the class CCHandler method handleCommand.

public static void handleCommand(String args, CommandObject command) {
    // cc lockout handling
    SplitFirstObject commandName = new SplitFirstObject(args);
    CCommandObject commandObject = command.guild.customCommands.getCommand(commandName.getFirstWord(), command);
    String ccArgs = commandName.getRest();
    if (ccArgs == null) {
        ccArgs = "";
    }
    if (commandObject == null)
        return;
    List<IChannel> ccDenied = command.guild.getChannelsByType(ChannelSetting.CC_DENIED);
    if (ccDenied.contains(command.channel.get())) {
        RequestHandler.sendMessage("> Custom Command usage has been disabled for this channel.", command.channel);
        return;
    }
    ProfileObject object = command.guild.users.getUserByID(command.user.longID);
    if (object != null && object.getSettings().contains(UserSetting.DENY_USE_CCS)) {
        RequestHandler.sendMessage("> Nothing interesting happens. `(ERROR: 403)`", command.channel.get());
        return;
    }
    command.guild.sendDebugLog(command, "CUSTOM_COMMAND", commandObject.getName(command), ccArgs);
    String contents = commandObject.getContents(true);
    // shitpost handling
    if (commandObject.isShitPost() && command.guild.config.shitPostFiltering && !GuildHandler.testForPerms(command, Permissions.MANAGE_CHANNELS)) {
        List<IChannel> channels = command.guild.getChannelsByType(ChannelSetting.SHITPOST);
        if (channels.size() != 0 && !channels.contains(command.channel.get())) {
            channels = command.user.getVisibleChannels(channels);
            List<String> channelMentions = Utility.getChannelMentions(channels);
            RequestHandler.sendMessage(Utility.getChannelMessage(channelMentions), command.channel.get());
            return;
        }
    }
    // tag handling
    for (TagObject t : TagList.getType(TagType.CC)) {
        contents = t.handleTag(contents, command, ccArgs);
        if (contents == null)
            return;
    }
    RequestHandler.sendMessage(contents, command.channel.get());
}
Also used : CCommandObject(com.github.vaerys.objects.CCommandObject) IChannel(sx.blah.discord.handle.obj.IChannel) TagObject(com.github.vaerys.templates.TagObject) SplitFirstObject(com.github.vaerys.objects.SplitFirstObject) ProfileObject(com.github.vaerys.objects.ProfileObject)

Example 4 with TagObject

use of com.github.vaerys.templates.TagObject in project DiscordSailv2 by Vaerys-Dawn.

the class JoinMessage method getContent.

public String getContent(CommandObject command) {
    List<TagObject> tags = TagList.getType(TagType.JOIN_MESSAGES);
    String message = content;
    for (TagObject t : tags) {
        message = t.handleTag(message, command, "");
    }
    return message;
}
Also used : TagObject(com.github.vaerys.templates.TagObject)

Example 5 with TagObject

use of com.github.vaerys.templates.TagObject in project DiscordSailv2 by Vaerys-Dawn.

the class DailyMessage method getContents.

public String getContents(CommandObject command) {
    String newContent = content;
    for (TagObject t : TagList.getType(TagType.DAILY)) {
        newContent = t.handleTag(newContent, command, "");
    }
    char[] prefixCheck = new char[4];
    newContent.getChars(0, 4, prefixCheck, 0);
    boolean found = false;
    for (char c : prefixCheck) {
        if (c == '>') {
            found = true;
        }
    }
    if (!found)
        newContent = "> " + newContent;
    return newContent;
}
Also used : TagObject(com.github.vaerys.templates.TagObject)

Aggregations

TagObject (com.github.vaerys.templates.TagObject)8 CCommandObject (com.github.vaerys.objects.CCommandObject)2 TagType (com.github.vaerys.enums.TagType)1 UserSetting (com.github.vaerys.enums.UserSetting)1 ProfileObject (com.github.vaerys.objects.ProfileObject)1 SplitFirstObject (com.github.vaerys.objects.SplitFirstObject)1 TagEmbedImage (com.github.vaerys.tags.cctags.TagEmbedImage)1 TagRemoveMentions (com.github.vaerys.tags.cctags.TagRemoveMentions)1 TagRemoveSanitizeTag (com.github.vaerys.tags.cctags.TagRemoveSanitizeTag)1 LinkedList (java.util.LinkedList)1 Random (java.util.Random)1 IChannel (sx.blah.discord.handle.obj.IChannel)1