Example #1
0
  public static void main(String[] args) {
    b.setVerbose(true);
    try {
      loadSettings();
    } catch (Exception e) {
      System.err.println("Failed to process config file: " + e.getMessage());
      System.exit(0);
    }

    try {
      b.setName(nick);
      b.connect(server);
      for (String s : channels) b.joinChannel(s);
    } catch (Exception e) {
      System.err.println("Could not connect to server: " + e.getMessage());
      System.exit(0);
    }
  }
Example #2
0
    public void checkDoor() {
      String x = "";
      while (true) {

        try {

          Thread.sleep(500);
          if (!getBash("cat door.txt")[0].equals(x)) {
            x = getBash("cat door.txt")[0];

            sendMessage(channel, "door iz " + getBash("cat door.txt")[0]);
          }

        } catch (Exception e) {
          System.out.println(e.getMessage());
          sendMessage(channel, e.getMessage());
        }
      }
    }
Example #3
0
    public String[] getBash(String command) {
      String[] cmd = {"/bin/sh", "-c", command};
      String[] out = new String[10];
      int i = 0;
      try {
        Process proc = Runtime.getRuntime().exec(cmd);
        BufferedReader read = new BufferedReader(new InputStreamReader(proc.getInputStream()));

        out[i] = read.readLine();
        while (read.ready() && i < 9) {

          out[i] = read.readLine();
          i++;
        }

      } catch (Exception e) {
        System.out.println(e.getMessage());
        sendMessage(channel, e.getMessage());
      }

      return out;
    }
Example #4
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;
  }