Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Reader.java
- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- import java.io.IOException;
- import java.net.MalformedURLException;
- import java.net.URL;
- public class Reader implements Runnable {
- public static int firstEmptyNode = 3333;
- public static String getNodeTitle(int node) {
- try {
- BufferedReader in = new BufferedReader(
- new InputStreamReader(
- new URL("http://www.quadropolis.us/node/" + node).openStream()
- )
- );
- String line;
- while((line = in.readLine()) != null) {
- //String line = in.readLine();
- if(line.startsWith("<title>") && line.endsWith(" | Quadropolis</title>"))
- return line.replace(" | Quadropolis</title>", "").replace("<title>", "");
- }
- }
- catch (MalformedURLException e) { return null; }
- catch (IOException e) { return null; }
- return null;
- }
- public void run() {
- while(true) {
- if (getNodeTitle(firstEmptyNode) == null) continue;
- else {
- //nodeTitle = getNodeTitle(node);
- //System.out.println(nodeTitle);
- firstEmptyNode++;
- }
- //System.out.println(firstEmptyNode);
- }
- }
- public static void main(String[] args) {
- for(int i = 3333 ; i < 3334 ; i++) System.out.println(Reader.getNodeTitle(i));
- //new Reader().run();
- //System.out.println(firstEmptyNode);
- //new Bot().initiateNode();
- //System.out.println(Bot.node);
- }
- }
- //--
- // Bot.java
- import org.jibble.pircbot.*;
- public class Bot extends PircBot implements Runnable {
- public static int node = 3333;
- public Bot() {
- this.setName("QuadroBot");
- this.setLogin("qbot");
- }
- public void initiateNode() {
- while(Reader.getNodeTitle(node) != null) {
- //System.out.println(Reader.getNodeTitle(node));
- node++;
- }
- }
- public void onMessage(String channel, String sender, String login, String hostname, String message) {
- if ((message.startsWith("-join")) && sender.equals("Chaos")) {
- joinChannel(message.substring(6,message.length()));
- }
- if ((message.startsWith("-part")) && sender.equals("Chaos")) {
- partChannel(message.substring(6,message.length()));
- }
- if ((message.startsWith("-nick")) && sender.equals("Chaos")) {
- changeNick(message.substring(6,message.length()));
- }
- }
- public void run() {
- while (true) {
- if (Reader.getNodeTitle(node) != null) {
- sendMessage("#sauer-scripts",
- Colors.BOLD + Reader.getNodeTitle(node)
- );
- initiateNode();
- }
- }
- }
- }
- // ---
- // BotMain.java
- public class BotMain {
- public static void main(String[] args) throws Exception {
- Bot bot = new Bot();
- bot.setVerbose(true);
- bot.connect("irc.gamesurge.net");
- bot.joinChannel("#sauer-scripts");
- //bot.initiateNode();
- new Thread(new Reader()).start();
- new Thread(bot).start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment