Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Input = $$heyo testing the code
- //Custom command json data
- {
- "name": "Heyo",
- "userID": "153159020528533505",
- "isLocked": false,
- "shitPost": true,
- "timesRun": 4,
- "contents": [
- "๐ Heyo is me your friend ๐ **#author#** ๐ and here we are to tell you about #args#!#!break#",
- "๐ ๐ #args# is such a great thing, I #author# could not tell you how much I love #args# ๐ฏ , #!break#",
- "its so great. ๐ hey guys have i told you about #args# yet i mean its so beautiful and amazing. **#args#** ๐ ๐"
- ]
- }
- public CCHandler(String command, String args, IMessage message) {
- this.command = command;
- this.args = args;
- this.message = message;
- guild = message.getGuild();
- channel = message.getChannel();
- author = message.getAuthor();
- guildID = guild.getID();
- customCommands = (CustomCommands) Utility.initFile(guildID, Constants.FILE_CUSTOM, CustomCommands.class);
- guildConfig = (GuildConfig) Utility.initFile(guildID, Constants.FILE_GUILD_CONFIG, GuildConfig.class);
- handleCommand();
- Utility.flushFile(guildID, Constants.FILE_CUSTOM, customCommands, customCommands.isProperlyInit());
- Utility.flushFile(guildID, Constants.FILE_GUILD_CONFIG, guildConfig, guildConfig.isProperlyInit());
- }
- private void handleCommand() {
- if (customCommands.checkblackList(args) !=null){
- Utility.sendMessage(customCommands.checkblackList(args),channel);
- }
- String response;
- for (CCommandObject cc : customCommands.getCommandList()) {
- if (cc.isShitPost() && guildConfig.doShitPostFiltering()) {
- if (guildConfig.getChannelTypeID(Constants.CHANNEL_SHITPOST) != null) {
- if (!channel.getID().equals(guildConfig.getChannelTypeID(Constants.CHANNEL_SHITPOST))) {
- return;
- }
- }
- }
- //when i put a breakpoint here it stops testing further after a while for some reason...
- if (command.equalsIgnoreCase(Constants.PREFIX_CC + cc.getName())) {
- response = cc.getContents(true);
- int argsCount = StringUtils.countMatches(response,"#args#");
- if (argsCount != 0){
- if (args.length()*argsCount > Globals.argsMax) {
- Utility.sendMessage("> Args to large for this command. Max args size : " + Globals.argsMax, channel);
- return;
- }
- }
- response = TagSystem.tagSystem(response, message, args);
- Utility.sendMessage(response, channel);
- }
- }
- }
- public String checkblackList(String args) {
- return Utility.checkBlacklist(args,blackList);
- }
- public static String checkBlacklist(String message, ArrayList<BlackListObject> blacklist) {
- for (BlackListObject b : blacklist) {
- if (message.toLowerCase().contains(b.getPhrase().toLowerCase())) {
- return b.getReason();
- }
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment