Vaerys_Dawn

weird as all hell

Oct 22nd, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.17 KB | None | 0 0
  1. //Input = $$heyo testing the code
  2.  
  3. //Custom command json data
  4.     {
  5.       "name": "Heyo",
  6.       "userID": "153159020528533505",
  7.       "isLocked": false,
  8.       "shitPost": true,
  9.       "timesRun": 4,
  10.       "contents": [
  11.         "๐ŸŽ‰ Heyo is me your friend ๐Ÿ‘  **#author#** ๐Ÿ‘ and here we are to tell you about #args#!#!break#",
  12.         "๐Ÿ‘ ๐Ÿ‘ #args# is such a great thing, I #author# could not tell you how much I love #args# ๐Ÿ’ฏ , #!break#",
  13.         "its so great. ๐Ÿ‘€ hey guys have i told you about #args# yet i mean its so beautiful and amazing. **#args#** ๐Ÿ‘Œ ๐Ÿ‘Œ"
  14.       ]
  15.     }
  16.  
  17.     public CCHandler(String command, String args, IMessage message) {
  18.         this.command = command;
  19.         this.args = args;
  20.         this.message = message;
  21.         guild = message.getGuild();
  22.         channel = message.getChannel();
  23.         author = message.getAuthor();
  24.         guildID = guild.getID();
  25.         customCommands = (CustomCommands) Utility.initFile(guildID, Constants.FILE_CUSTOM, CustomCommands.class);
  26.         guildConfig = (GuildConfig) Utility.initFile(guildID, Constants.FILE_GUILD_CONFIG, GuildConfig.class);
  27.         handleCommand();
  28.         Utility.flushFile(guildID, Constants.FILE_CUSTOM, customCommands, customCommands.isProperlyInit());
  29.         Utility.flushFile(guildID, Constants.FILE_GUILD_CONFIG, guildConfig, guildConfig.isProperlyInit());
  30.     }
  31.  
  32.     private void handleCommand() {
  33.         if (customCommands.checkblackList(args) !=null){
  34.             Utility.sendMessage(customCommands.checkblackList(args),channel);
  35.         }
  36.         String response;
  37.         for (CCommandObject cc : customCommands.getCommandList()) {
  38.             if (cc.isShitPost() && guildConfig.doShitPostFiltering()) {
  39.                 if (guildConfig.getChannelTypeID(Constants.CHANNEL_SHITPOST) != null) {
  40.                     if (!channel.getID().equals(guildConfig.getChannelTypeID(Constants.CHANNEL_SHITPOST))) {
  41.                         return;
  42.                     }
  43.                 }
  44.             }
  45.             //when i put a breakpoint here it stops testing further after a while for some reason...
  46.             if (command.equalsIgnoreCase(Constants.PREFIX_CC + cc.getName())) {
  47.                 response = cc.getContents(true);
  48.                 int argsCount = StringUtils.countMatches(response,"#args#");
  49.                 if (argsCount != 0){
  50.                     if (args.length()*argsCount > Globals.argsMax) {
  51.                         Utility.sendMessage("> Args to large for this command. Max args size : " + Globals.argsMax, channel);
  52.                         return;
  53.                     }
  54.                 }
  55.                 response = TagSystem.tagSystem(response, message, args);
  56.                 Utility.sendMessage(response, channel);
  57.             }
  58.         }
  59.     }
  60.  
  61.     public String checkblackList(String args) {
  62.         return Utility.checkBlacklist(args,blackList);
  63.     }
  64.  
  65.     public static String checkBlacklist(String message, ArrayList<BlackListObject> blacklist) {
  66.         for (BlackListObject b : blacklist) {
  67.             if (message.toLowerCase().contains(b.getPhrase().toLowerCase())) {
  68.                 return b.getReason();
  69.             }
  70.         }
  71.         return null;
  72.     }
Advertisement
Add Comment
Please, Sign In to add comment