@Override public void exec(Sys sys, User user, Group group, String used, String[] args, Message message) { if (args.length < 2) { sendUsage(sys, user, group); } else { Show show = SuperBotShows.getShow(args[0]); String ep = args[1].toUpperCase(); MessageBuilder<?> mb = sys.message(); if (show == null) { group.sendMessage(mb.escaped("Invalid show name: " + args[0])); } else if (ep.equalsIgnoreCase("none") || ep.equalsIgnoreCase("remove")) { Map<String, String> prg = SuperBotController.getProgress(show); prg.remove(user.getUsername()); SuperBotController.PROGRESS.put(show.getMainName(), prg); group.sendMessage( mb.escaped( "Removed " + user.getDisplayName().orElse(user.getUsername()) + "'s progress on ") .bold(true) .escaped(show.getDisplay())); SuperBotController.saveProgress(); } else if (!SuperBotShows.EPISODE_PATTERN.matcher(ep).matches()) { group.sendMessage(mb.escaped("Invalid episode: " + ep + " (doesn't match SxEyy format)")); } else { Map<String, String> prg = SuperBotController.getProgress(show); prg.put(user.getUsername(), ep); SuperBotController.PROGRESS.put(show.getMainName(), prg); group.sendMessage( mb.escaped( "Set " + user.getDisplayName().orElse(user.getUsername()) + "'s progress on ") .bold(true) .escaped(show.getDisplay()) .bold(false) .escaped(" to " + ep)); SuperBotController.saveProgress(); } } }
@Override public void exec(Sys sys, User user, Group group, String used, String[] args, Message message) { if (args.length == 0) { this.sendUsage(sys, user, group); } else { MessageBuilder mb = sys.message(); Show show = SuperBotShows.getShow(args[0]); if (show != null) { if (SuperBotShows.removeLink(args[0])) { group.sendMessage( mb.bold(true) .escaped("Removed link (" + args[0] + ") from: ") .bold(false) .escaped(show.getDisplay())); } else { group.sendMessage(mb.escaped("Something went wrong.")); } } else { group.sendMessage(mb.escaped("I couldn't find a show with the name \"" + args[0] + "\"")); } } }