1

Doing a twitchbot as a little hobby project and stumble om a little problem. I want to make a viewer list where it automatically shows when viewers enter my channel. The problem i got is that the list that is being retrieved only shows the bot. I have read through the javadocs and i thought that i did everything correctly but i just cant get it to work.

So when the bot connects to a server the onuserlist() method is called and retrieves a userlist, but the only user it gets is the bot. Even if i got 5, 10, 100 people in my channel.

@Override
    protected void onUserList(String channel, User[] users) {

        for (User user1 : users) {
            System.out.println(user1);
            model.addElement(user1.getNick());
        }
        super.onUserList(channel, users);

    }

The onjoin() method should update the userlist with the following piece of code and it is called everytime someone joins. But even here it is the same problem, the only user that it can find is the bot. I wonder know if someone has got a better knowledge about pircbots and knows what i might be doing wrong?

  User[] user=bot.getUsers("#mychannel");
        for(int i =0; i<user.length;i++){
            System.out.println(user[i]);
    }

According to the java doc it should give me a User array of all the people in my channel, but it only gives me one.

http://www.jibble.org/javadocs/pircbot/

user3611818
  • 247
  • 2
  • 3
  • 13

2 Answers2

0
User[] user=bot.getUsers("#mychannel");
   for (User usr : user){
         System.out.println(usr.toString());
     }
}  
Tim
  • 1
  • 1
  • I took your example and pasted it into my code and it works perfectly. After your bot logs in, check the user list of the room you are logging into with another IRC Client. Make sure you see your bot name in the user list. It may be possible that you are logging into a room with no one else in it. – Tim Jun 10 '16 at 13:17
0

So I just figured this problem out today, if you are using the JOIn/Part system, you need to request permission from the server when you connect using

bot_Object.sendRawLine("CAP REQ :twitch.tv/membership");

This lets Twitch know that you want to use the Join/Part capabilities.

If you want to know more, here is their help guide for setting up different IRC clients, I just pulled the command for permission and used it in my bot.

http://help.twitch.tv/customer/portal/articles/1302780-twitch-irc

Thorinori
  • 1
  • 1