コード例 #1
0
 @Override
 public boolean execute(MessageEvent event) throws Exception {
   if (event.getUser() == null) {
     return false;
   }
   if (PermissionManager.hasExec(event.getUser().getNick())) {
     String[] args = event.getMessage().split(" ");
     if (args.length == 2 && args[1].length() == 1) {
       String oldtrigger = config.getTrigger();
       config.setTrigger(args[1]);
       if (config.useDatabase)
         Main.database
             .prepareStatement(
                 "UPDATE `Bot` SET `Bot_Trigger` = '"
                     + config.getTrigger()
                     + "' WHERE `Bot`.`Nick` = '"
                     + event.getBot().getUserBot().getNick()
                     + "';")
             .execute();
       MessageUtils.sendUserNotice(
           event, "Bot prefix was set to " + config.getTrigger() + " from " + oldtrigger);
       return true;
     } else {
       return false;
     }
   } else {
     event.respond("You need to be Exec to change prefix!");
   }
   return false;
 }
コード例 #2
0
  @Override
  public boolean execute(MessageEvent event) throws Exception {
    String[] args = event.getMessage().split(" ");
    if (args.length == 2) {
      if (args[1].equalsIgnoreCase("again")) {
        MessageUtils.sendUserNotice(event, "Removing old login!");
        Main.Login.remove(event.getUser().getNick());
        Main.NotLoggedIn.remove(event.getUser().getNick());
        MessageUtils.sendUserNotice(event, "Logging in...");
        String account = Utils.getAccount(event.getUser(), event);
        Main.Login.put(event.getUser().getNick(), account);
        MessageUtils.sendUserNotice(event, "Logged in!");
        return true;
      }
      if (args[1].equalsIgnoreCase("info")) {
        MessageUtils.sendUserNotice(
            event, "You are logged in as: " + Main.Login.get(event.getUser().getNick()));
        MessageUtils.sendUserNotice(
            event,
            "You are in group: "
                + Group(
                    Main.Login.get(event.getUser().getNick()),
                    event.getChannel().getName().toLowerCase()));
        return true;
      }
    }

    if (Main.Login.containsKey(event.getUser().getNick())
        && !Main.NotLoggedIn.contains(event.getUser().getNick())) {
      MessageUtils.sendUserNotice(
          event,
          "You are already logged in! If you want to update login, use \""
              + config.getTrigger()
              + "login again\"");
      return true;
    }
    String account = Utils.getAccount(event.getUser(), event);
    Main.Login.put(event.getUser().getNick(), account);
    Main.NotLoggedIn.remove(event.getUser().getNick());
    MessageUtils.sendUserNotice(event, "You are now Logged in!");
    return true;
  }