예제 #1
0
파일: Arisu.java 프로젝트: Carlgo11/Arisu
 public boolean onPartAll(String sender, String reason) {
   int d = channels.size();
   d--;
   for (int i = 0; i <= channels.size(); i++) {
     boolean f = inChannel(channels.get(d));
     if (!f) {
       return true;
     } else {
       try {
         if (reason == null) {
           this.partChannel(
               channels.get(i),
               config.getProperty("disconnect-message") + "  (Requested by " + sender + ")");
         } else {
           this.partChannel(
               channels.get(i),
               config.getProperty("disconnect-message")
                   + " (Reason: "
                   + reason
                   + "  (Requested by "
                   + sender
                   + "))");
         }
       } catch (Exception ex) {
         return true;
       }
     }
   }
   return false;
 }
예제 #2
0
파일: Arisu.java 프로젝트: Carlgo11/Arisu
 public boolean inChannel(String channel) {
   boolean outp = false;
   for (int i = 0; i < channels.size(); i++) {
     if (channels.get(i).equalsIgnoreCase(channel)) {
       outp = true;
     }
   }
   return outp;
 }
예제 #3
0
파일: Arisu.java 프로젝트: Carlgo11/Arisu
 public void removeChannel(String channel, String sender) throws IOException {
   File file = new File("channels.txt");
   FileWriter d = new FileWriter(file);
   channels.remove(channel);
   StringBuilder f = new StringBuilder();
   for (int i = 0; i < channels.size(); i++) {
     if (!channels.get(i).equalsIgnoreCase(channel)) {
       f.append(channels.get(i).toString().toLowerCase());
       f.append("\n");
     }
   }
   d.flush();
   d.write(f.toString());
   d.close();
 }
예제 #4
0
 public boolean checkMod(String user) {
   if (mods.contains(user)) {
     return true;
   } else {
     return false;
   }
 }
예제 #5
0
파일: Arisu.java 프로젝트: Carlgo11/Arisu
 public boolean isMod(String sender) {
   if (mods.contains(sender)) {
     return true;
   } else {
     return false;
   }
 }
예제 #6
0
파일: Arisu.java 프로젝트: Carlgo11/Arisu
 public boolean isAdmin(String sender) {
   if (admins.contains(sender)) {
     return true;
   } else {
     return false;
   }
 }
예제 #7
0
파일: Arisu.java 프로젝트: Carlgo11/Arisu
 public void appendChannel(String channel, String sender) throws IOException {
   File file = new File("channels.txt");
   FileWriter d = new FileWriter(file);
   channels.add(channel.toLowerCase());
   StringBuilder f = new StringBuilder();
   for (int i = 0; i < channels.size(); i++) {
     f.append(channels.get(i).toString());
     f.append("\n");
   }
   System.out.println("f:" + f.toString());
   d.flush();
   d.write(f.toString());
   d.close();
   this.joinChannel(channel);
   this.sendMessage(channel, "Hello ya'll. I was invited by " + sender + ".");
 }
예제 #8
0
파일: Arisu.java 프로젝트: Carlgo11/Arisu
 public void onInvite(
     String targetNick, String sender, String sourceLogin, String sourceHostname, String channel) {
   if (!ignored.contains(channel)) {
     try {
       this.appendChannel(channel, sender);
     } catch (IOException ex) {
       this.sendError(sender, ex.toString());
     }
   } else {
     ignoredChannel(sender, channel);
   }
 }
예제 #9
0
  public static Plugin loadPlugin(String name) {
    try {
      ArrayList<URL> paths = new ArrayList<URL>();
      File f = new File("plugins/" + name + ".jar");
      paths.add(f.toURI().toURL());

      File f2 = new File("plugins/lib");
      for (File ff : f2.listFiles()) {
        paths.add(ff.toURI().toURL());
      }
      URL[] urls = new URL[paths.size()];
      paths.toArray(urls);
      URLClassLoader newLoader = new URLClassLoader(urls);
      Plugin p = (Plugin) newLoader.loadClass(name).newInstance();
      loadedPlugins.put(name, p);
      return p;
    } catch (Exception ex) {
      System.err.println("Failed to load plugin: " + ex.getMessage());
      ex.printStackTrace();
    }
    return null;
  }
예제 #10
0
  private static void loadSettings() throws Exception {
    String context = "", line;
    FileReader fr = new FileReader("config");
    BufferedReader br = new BufferedReader(fr);

    while ((line = br.readLine()) != null) {
      if (line.startsWith("[") && line.endsWith("]")) {
        context = line.substring(1, line.length() - 1);
      } else {
        if (line.trim().length() == 0) continue;
        else if (context.equals("nick")) nick = line;
        else if (context.equals("server")) server = line;
        else if (context.equals("channels")) channels.add(line);
        else if (context.equals("plugins")) loadPlugin(line);
      }
    }
  }
예제 #11
0
  public void onMessage(
      String channel, String sender, String login, String hostname, String message) {
    if (message.equalsIgnoreCase("!goaway")) {
      if (sender.equals(BotOP) || sender.equals(BotOP2)) {
        partChannel(channel, "Fine, I'll leave quietly.");
      } else {
        sendMessage(channel, "Only the main operator can use this command.");
      }
    }
    if (message.contains("!game")) {
      String[] parts = message.split(" ");
      if (parts[1].equalsIgnoreCase("genesis")) {
        if (parts[2].equals("1")) {
          sendMessage(channel, "Name: Sonic the Hedgehog; Release date: 1991-06-23;");
        }
        if (parts[2].equals("2")) {
          sendMessage(channel, "Name: Sonic the Hedgehog 2; Release date: 1992-11-24;");
        }
        if (parts[2].equals("3")) {
          sendMessage(
              channel,
              "Name: Sonic the Hedgehog 3 (and Knuckles); Release date: 1994-02-02 (1994-08-18)");
        }
        if (parts[2].equalsIgnoreCase("spinball")) {
          sendMessage(channel, "Name: Sonic Spinball; Initial US Release date: 1993-11-23;");
        }
        if (parts[2].equalsIgnoreCase("3dblast")) {
          sendMessage(channel, "Name: Sonic 3D Blast; Genesis release date: 1996-11-12;");
        }
      }
      if (parts[1].equalsIgnoreCase("saturn")) {
        if (parts[2].equalsIgnoreCase("r")) {
          sendMessage(channel, "Name: Sonic R; Release date: 1997-11-18;");
        }
        if (parts[2].equalsIgnoreCase("3dblast")) {
          sendMessage(channel, "Name: Sonic 3D Blast; Saturn release date: 1996-11-20;");
        }
      }
      if (parts[1].equalsIgnoreCase("dreamcast")) {
        if (parts[2].equalsIgnoreCase("adventure")) {
          if (parts.length == 4) {
            if (parts[3].equals("2")) {
              sendMessage(channel, "Name: Sonic Adventure 2; Release date: 2001-06-19;");
            }
          } else {
            sendMessage(channel, "Name: Sonic Adventure; Release date: 1998-12-23;");
          }
        }
        if (parts[2].equalsIgnoreCase("shuffle")) {
          sendMessage(channel, "Name: Sonic Shuffle; Release date: 2000-11-14;");
        }
      }
    }
    if (message.equalsIgnoreCase("!didit")) {
      if (jokesPub) {
        sendMessage(channel, "I DID IT! \\o/");
      } else {
        if (sender.equals(BotOP) || sender.equalsIgnoreCase(BotOP2) || checkMod(sender)) {
          sendMessage(channel, "I DID IT! \\o/");
        } else {
          return;
        }
      }
    }
    if (message.equalsIgnoreCase("!isayhey")) {
      if (channel.equals("")) {
        return;
      } else {
        if (jokesPub) {
          sendMessage(channel, "What's going on?");
        } else {
          if (sender.equals(BotOP) || sender.equals("BotOP2") || checkMod(sender)) {
            sendMessage(channel, "What's going on?");
          } else {
            return;
          }
        }
      }
    }
    if (message.equals("!jokes")) {
      if (sender.equals(BotOP) || sender.equals(BotOP2) || checkMod(sender)) {
        jokesPub = !jokesPub;
        sendMessage(channel, "Joke commands toggled!");
      } else {
        sendMessage(channel, "Only the current operator can toggle joke commands!");
      }
    }
    if (message.equalsIgnoreCase("!source")) {
      sendMessage(
          channel, sender + ": My source code is at http://www.github.com/MineRobber9000/KintoBot");
      sendMessage(
          channel,
          sender + ": It may not be up to date though, my creator works on my code a lot.");
    }
    if (message.contains("!kb")) {
      if (sender.equals(BotOP)) {
        String[] parts = message.split(" ");
        if (parts[1].equalsIgnoreCase("dumpvars")) {
          sendMessage(
              channel,
              "The sender is "
                  + sender
                  + ", the channel was "
                  + channel
                  + ", the login variable was "
                  + login
                  + ", the hostname is "
                  + hostname
                  + ", and the message was "
                  + message
                  + ".");
        }
        if (parts[1].equalsIgnoreCase("botop2")) {
          if (parts[2].equalsIgnoreCase("clear")) {
            BotOP2 = "";
          } else {
            BotOP2 = parts[2];
          }
        }
        if (parts[1].equalsIgnoreCase("mods")) {
          if (parts.length == 4) {
            switch (parts[2]) {
              case "add":
                mods.add(parts[3]);
                break;
              case "rm":
                mods.remove(parts[3]);
                break;
            }
          } else {
            if (parts[2].equalsIgnoreCase("wipe")) {
              mods = new ArrayList<String>();
            } else {
              sendMessage(channel, "Mods: " + mods.toString());
            }
          }

          if (parts[2].equalsIgnoreCase("check")) {
            if (checkMod(parts[3])) {
              sendMessage(channel, BotOP + ": Yes, " + parts[3] + " is a mod.");
            } else {
              sendMessage(channel, BotOP + ": No, " + parts[3] + " is not a mod.");
            }
          }
        }
        if (parts[1].equalsIgnoreCase("passop")) {
          BotOP = parts[2];
        }
      } else {
        sendMessage(channel, "Only the current main operator can configure KintoBot.");
      }
    }
  }