我的 PIRC 机器人代码做错了什么?

What am I doing wrong in my PIRC bot code?

我一直收到这个错误

1428460892508 :Monstarules!webchat@ool-43563441.dyn.optonline.net PRIVMSG #botte
ster :!pc.babel
1428460892510 ### Your implementation of PircBot is faulty and you have
1428460892510 ### allowed an uncaught Exception or Error to propagate in your
1428460892511 ### code. It may be possible for PircBot to continue operating
1428460892511 ### normally. Here is the stack trace that was produced: -
1428460892511 ###
1428460892511 ### java.lang.NoClassDefFoundError: org/jsoup/Jsoup
1428460892512 ###       at MyBot.onMessage(MyBot.java:20)
1428460892512 ###       at org.jibble.pircbot.PircBot.handleLine(PircBot.java:99
0)
1428460892512 ###       at org.jibble.pircbot.InputThread.run(InputThread.java:9
2)
1428460892512 ### Caused by: java.lang.ClassNotFoundException: org.jsoup.Jsoup
1428460892513 ###       at java.net.URLClassLoader.findClass(URLClassLoader.java
:381)
1428460892513 ###       at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

1428460892513 ###       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.j
ava:331)
1428460892514 ###       at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

1428460892514 ###       ... 3 more

来自以下代码。

import org.jibble.pircbot.*;
import org.jsoup.*;
import org.jsoup.helper.*;
import org.jsoup.nodes.*;
import org.jsoup.select.*;
import java.io.*;

public class MyBot extends PircBot {
    public MyBot() {
        this.setName("^MonstaBot^");
    }
    public void onMessage(String channel, String sender, String login, String hostname, String message) {
        if(sender.equalsIgnoreCase("monstarules") && message.equalsIgnoreCase("!quit")){
            quitServer("Good bye!");
        }
        if(message.equalsIgnoreCase("!pc.babel")) {
            String playerList = new String();
            Document doc = null;
            try {
                doc = Jsoup.connect("http://aos075.aloha.pk:34886/").get();
                String text = doc.html();
                FileWriter fw = new FileWriter("temp1.txt");
                fw.write(text);
                fw.close();
                BufferedReader br = new BufferedReader(new FileReader("temp1.txt"));

                for(int i = 0; i < 103; ++i)
                br.readLine();
                text = br.readLine();
                text = text.trim();
                text = text.replaceAll("<br>", "").replaceAll("<p>", "").replaceAll("</p>", "");
                text = text.replace("Hello! Welcome to the status server for aloha.pk tower of babel. ", "");
                int stlg = text.length() - 1;

                for(int i = (stlg - 22); stlg > i; i++) {
                    String tw = "" + text.charAt(i);
                    playerList = playerList + tw;
                }
                sendMessage(channel, playerList);
            }
            catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

出于某种原因,我觉得这非常简单。我写的原始代码是:

import java.io.*;
import org.jsoup.*;
import org.jsoup.helper.*;
import org.jsoup.nodes.*;
import org.jsoup.select.*;

public class Scraper {
    public static void derp() throws IOException {
        String playerList = new String();

        Document doc = null;
        try {
            doc = Jsoup.connect("http://aos075.aloha.pk:34886/").get();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        String text = doc.html();

        FileWriter fw = new FileWriter("temp1.txt");
        fw.write(text);
        fw.close();

        BufferedReader br = new BufferedReader(new FileReader("temp1.txt"));

        for(int i = 0; i < 103; ++i)
        br.readLine();
        text = br.readLine();
        text = text.trim();
        text = text.replaceAll("<br>", "").replaceAll("<p>", "").replaceAll("</p>", "");
        text = text.replace("Hello! Welcome to the status server for aloha.pk tower of babel. ", "");
        int stlg = text.length() - 1;

        for(int i = (stlg - 22); stlg > i; i++) {
            String tw = "" + text.charAt(i);
            playerList = playerList + tw;
        }
        System.out.print(playerList);
    }
    public static void main(String[] args) throws IOException {
        derp();
    }
}

原始代码有效,但是每当我尝试将其作为一个方法并将其插入 botcode 时,我总是会遇到错误,当我更正它们时,当我尝试为 [= 调用触发器时会弹出更多13=]。谁能帮我理解错误?

这个错误很关键,java.lang.NoClassDefFoundError: org/jsoup/Jsoup。这意味着 Jsoup JAR 不在您的应用程序类路径中。您如何开始和 运行 设置您的机器人?这与您的开始方式和 运行 您的原始代码有何不同?