简体   繁体   中英

Method connect() from type PircBotX not visible

I am trying to create a bot using PircBotX, however I am unable to even get started making it. Using just the basic example code, I am unable to get the connect() method to work, it always give the error at compile mentioned in the title. Here is the code I am using:

import org.pircbotx.Configuration;
import org.pircbotx.PircBotX;

public class MyBot {
    public static void main(String[] args) throws Exception {
        Configuration configuration = new Configuration.Builder()
        .setName("PircBotX") //Set the nick of the bot. CHANGE IN YOUR CODE
        .setLogin("LQ") //login part of hostmask, eg name:login@host
        .setAutoNickChange(true) //Automatically change nick when the current one is in use
        .setCapEnabled(true) //Enable CAP features
        .setServerHostname("irc.freenode.net")
        .addAutoJoinChannel("#pircbotx") //Join the official #pircbotx channel
        .buildConfiguration();
        PircBotX bot = new PircBotX(configuration);

        //Connect to server
        try {
            bot.connect();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

The error occurs with the line bot.connect();

PircBotX can be found at its Google Code page: https://code.google.com/p/pircbotx/

On the docs , there is a method called startBot() , should that be used instead?

void startBot() Start the bot by connecting to the server.

import org.pircbotx.Configuration;
import org.pircbotx.PircBotX;

public class MyBot {
    public static void main(String[] args) throws Exception {
        Configuration configuration = new Configuration.Builder()
        .setName("PircBotX") //Set the nick of the bot. CHANGE IN YOUR CODE
        .setLogin("LQ") //login part of hostmask, eg name:login@host
        .setAutoNickChange(true) //Automatically change nick when the current one is in use
        .setCapEnabled(true) //Enable CAP features
        .setServerHostname("irc.freenode.net")
        .addAutoJoinChannel("#pircbotx") //Join the official #pircbotx channel
        .buildConfiguration();
        PircBotX bot = new PircBotX(configuration);

        //Connect to server
        try {
            //bot.connect();
            bot.startBot();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM