(PircBotX, Java и Twitch) Как мне применить этот объект? - PullRequest
1 голос
/ 02 июня 2019

Я пытаюсь использовать Pircbotx в качестве библиотеки для приложения Android. Pircbotx должен использоваться исключительно для чата Twitch.tv, поэтому я добавил код поддержки Twitch, как указано здесь . У меня проблемы с объектом конфигурации или как может быть путь к библиотекам?

Оригинальный выпуск:

https://i.imgur.com/KFSky7h.png

Странно, если вы закомментируете addListneer (), проблема исчезнет

https://i.imgur.com/sKpMJG4.png

Наконец, если я изменю конструктор с учетом предложенного исправления Android Studio, конструктор Pircbotx не примет этот объект конфигурации.

https://i.imgur.com/K4q9QUV.png

Может ли кто-нибудь указать мне правильное направление?

Для копирования / вставки ссылки:

public void Connect() throws Exception {
    //Configure what we want our bot to do
    Configuration.Builder configuration = new Configuration.Builder().setAutoNickChange(false) //Twitch doesn't support multiple users
    .setOnJoinWhoEnabled(false) //Twitch doesn't support WHO command
    .setCapEnabled(true).addCapHandler(new EnableCapHandler("twitch.tv/membership")) //Twitch by default doesn't send JOIN, PART, and NAMES unless you request it, see https://dev.twitch.tv/docs/irc/guide/#twitch-irc-capabilities
    .addServer("irc.twitch.tv").setName("MyTwitchUsername") //Your twitch.tv username
    .setServerPassword("oauth:bigAlphanumericString") //Your oauth password from http://twitchapps.com/tmi
    .addAutoJoinChannel("#vgbootcamp") //Some twitch channel
    .addListener(new MyListener());
    //The rest of your config...
    //Create our bot with the configuration
    PircBotX bot = new PircBotX(configuration);
    //Connect to the server
    bot.startBot();
}

1 Ответ

0 голосов
/ 07 июня 2019

Добавьте следующую строку и попробуйте.

Configuration _configuration = configuration.buildConfiguration();
PircBotX bot = new PircBotX(_configuration);

PircBotX объект ожидает Configuration объект, а не Configuration.Builder объект

Вы должны фактически переименовать объект строителя в builder, как показано ниже

public void Connect() throws Exception {
    //Configure what we want our bot to do
    Configuration.Builder builder = new Configuration.Builder().setAutoNickChange(false) //Twitch doesn't support multiple users
    .setOnJoinWhoEnabled(false) //Twitch doesn't support WHO command
    .setCapEnabled(true).addCapHandler(new EnableCapHandler("twitch.tv/membership")) //Twitch by default doesn't send JOIN, PART, and NAMES unless you request it, see https://dev.twitch.tv/docs/irc/guide/#twitch-irc-capabilities
    .addServer("irc.twitch.tv").setName("MyTwitchUsername") //Your twitch.tv username
    .setServerPassword("oauth:bigAlphanumericString") //Your oauth password from http://twitchapps.com/tmi
    .addAutoJoinChannel("#vgbootcamp") //Some twitch channel
    .addListener(new MyListener());
    //The rest of your config...
    //Create our bot with the configuration
    Configuration configuration = builder.buildConfiguration();
    PircBotX bot = new PircBotX(configuration);
    //Connect to the server
    bot.startBot();
}
...