Exemple #1
0
 public BotClass(String name) {
   setName(name);
   cleanChats();
   cleanJO();
   cleanIgnore();
   try {
     bR = new BufferedWriter(new FileWriter("thread.txt"));
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Exemple #2
0
 public static void main(String[] args) {
   BotClass bot = new BotClass("dudeimmike");
   try {
     bot.setVerbose(true);
     bot.connect("irc.hackthissite.org");
     bot.sendMessage("nickserv", "IDENTIFY <your password>");
     bot.setVersion(bot.getName());
     bot.joinChannel("#bottest");
     // bot.setMode("#bots","+B");
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Exemple #3
0
 public void onMessage(
     String channel, String sender, String login, String hostname, String message) {
   if (tellme) {
     sendNotice(
         tellMeP,
         "Recieved message: " + message + "; Sender: " + sender + "; Channel: " + channel);
     try {
       bR.write("Recieved message: " + message + "; Sender: " + sender + "; Channel: " + channel);
       bR.newLine();
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
  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);
    }
  }
Exemple #5
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());
        }
      }
    }
Exemple #6
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;
    }
  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;
  }
Exemple #8
0
 public void onNotice(
     String sourceNick, String sourceLogin, String sourceHostname, String target, String notice) {
   if (tellme) {
     sendNotice(tellMeP, sourceNick + " sent notice: " + notice);
   }
   if (sourceNick.equalsIgnoreCase("vavsucks") && notice.contains("change")) {
     if (notice.contains("change mode +")) {
       setMode("#bottest", notice.replace("change mode ", ""));
       sendNotice(sourceNick, "Mode changed to " + notice.replace("change mode ", ""));
     } else if (notice.contains("change name ")) {
       setName(notice.replace("change name ", ""));
       sendNotice(sourceNick, "Name changed to " + notice.replace("change name ", ""));
     }
   } else if (notice.contains("jChannel = ")) {
     if (notice.contains("#")) {
       notice = notice.replace("#", "");
     }
     joinChannel("#" + notice.replace("jChannel = ", ""));
     sendNotice(sourceNick, "Joined channel #" + notice.replace("jChannel = ", ""));
     // setMode("#"+notice.replace("change jChannel = ", ""),"+B");
   } else if (notice.contains("lChannel = ")) {
     if (notice.contains("#")) {
       notice = notice.replace("#", "");
     }
     sendMessage("#" + notice.replace("lChannel = ", ""), "cya");
     partChannel("#" + notice.replace("lChannel = ", ""));
     sendNotice(sourceNick, "Left channel #" + notice.replace("lChannel = ", ""));
   } else if (notice.equalsIgnoreCase("tellme")) {
     tellme = true;
   } else if (notice.equalsIgnoreCase("donttellme")) {
     tellme = false;
   } else if (notice.equalsIgnoreCase("startrecorder")) {
     if (bR == null) {
       try {
         bR = new BufferedWriter(new FileWriter(notice.replace("startrecorder", "") + ".txt"));
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   } else if (notice.equalsIgnoreCase("endrecorder")) {
     if (bR != null) {
       try {
         bR.close();
         bR = null;
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   } else if (notice.contains("getCommands")) {
     sendNotice(sourceNick, "~Commands~");
     sendNotice(sourceNick, "change mode <mode:String>");
     sendNotice(sourceNick, "change name <name:String>");
     sendNotice(sourceNick, "change jChannel = <channel:String> ~ Joins channel");
     sendNotice(sourceNick, "change lChannel = <channel:String> ~ Leaves channel");
     sendNotice(sourceNick, "getCommands ~ Shows this");
     sendNotice(sourceNick, "tellme ~ Makes me show you whats happn'n");
     sendNotice(sourceNick, "donttellme ~ I won't tell you whats happn'n");
     sendNotice(
         sourceNick,
         "startrecorder <FileName:String> ~ Starts chat recorder, if not already started.");
     sendNotice(sourceNick, "endrecorder ~ Finish recording the Chat.");
   }
 }