Пример #1
0
 @Override
 public void exec(Sys sys, User user, Group group, String used, String[] args, Message message) {
   MessageBuilder mb = sys.message();
   if (args.length == 0) {
     Optional<Profile> prof = user.getProfile();
     if (prof.isPresent()) {
       mb.bold(true).escaped("Your profile (" + prof.get().getName() + "):").bold(false);
       for (Entry<String, String> acc : prof.get().getAccounts().entrySet()) {
         Sys sy = SuperBotController.PROVIDERS.get(acc.getKey());
         mb.newLine()
             .escaped(
                 "   "
                     + acc.getKey()
                     + ": "
                     + (sy != null ? sy.getUserFriendlyName(acc.getValue()) : acc.getValue()));
       }
     } else {
       this.sendNoProfile(sys, user, group);
       return;
     }
   } else {
     String s = sys.isUIDCaseSensitive() ? args[0] : args[0].toLowerCase();
     Optional<Profile> prof = Profile.get(sys, s);
     if (prof.isPresent()) {
       mb.bold(true).escaped(" " + s + "'s profile (" + prof.get().getName() + "):").bold(false);
       for (Entry<String, String> acc : prof.get().getAccounts().entrySet()) {
         Sys sy = SuperBotController.PROVIDERS.get(acc.getKey());
         mb.newLine()
             .escaped(
                 "   "
                     + acc.getKey()
                     + ": "
                     + (sy != null ? sy.getUserFriendlyName(acc.getValue()) : acc.getValue()));
       }
     } else {
       mb.escaped("No profile with (provider: " + sys.getName() + ", name: " + s + ")");
     }
   }
   group.sendMessage(mb);
 }
  @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();
      }
    }
  }
Пример #3
0
 @Override
 public String[] help(User user, boolean userchat) {
   return new String[] {
     "(uid)", "get yours or (uid)'s " + user.getProvider().getName() + " profile"
   };
 }