pircbotx / pircbotx

Modern Java IRC Library
http://pircbotx.github.io/pircbotx/latest/apidocs/
220 stars 72 forks source link

Not receiving messages #317

Closed WoutDev closed 6 years ago

WoutDev commented 8 years ago

Hello,

Using this code the onMessage and onGenericMessage listeners are not called:

public class Main extends ListenerAdapter implements Listener
{
    public static void main(String[] args) throws IOException, IrcException
    {
        PircBotX bot = new PircBotX(new Configuration.Builder().setAutoNickChange(false).setOnJoinWhoEnabled(false).setCapEnabled(true).addCapHandler(new EnableCapHandler("twitch.tv/membership")).addServer(
                "54.191.137.185", 80).setName("Wout_").setServerPassword("oauth:myOAuth").addAutoJoinChannel("#Wout_").addListener(new Main()).buildConfiguration());
        bot.startBot();
    }

    @Override
    public void onJoin(JoinEvent event) throws Exception
    {
        event.getChannel().send().message("Hello World!");
    }

    @Override
    public void onMessage(MessageEvent event) throws Exception
    {
        System.out.println("Message received from onMessage: " + event.getMessage());
    }

    @Override
    public void onGenericMessage(GenericMessageEvent event) throws Exception
    {
        System.out.println("Message received from onGenericMessage: " + event.getMessage());
    }
}

Log:

[main] INFO org.pircbotx.PircBotX - ---Starting Connect attempt 1/5---
[main] INFO org.pircbotx.PircBotX - Connected to server.
[main] INFO org.pircbotx.output.OutputRaw - CAP LS
[main] INFO org.pircbotx.output.OutputRaw - PASS oauth:OAuth
[main] INFO org.pircbotx.output.OutputRaw - NICK Wout_
[main] INFO org.pircbotx.output.OutputRaw - USER PircBotX 8 * :PircBotX 2.1 Java IRC bot - github.com/thelq/pircbotx
[main] INFO org.pircbotx.InputParser - :tmi.twitch.tv CAP * LS :twitch.tv/tags twitch.tv/commands twitch.tv/membership
[main] INFO org.pircbotx.output.OutputRaw - CAP REQ :twitch.tv/membership
[main] INFO org.pircbotx.InputParser - :tmi.twitch.tv 001 wout_ :Welcome, GLHF!
[main] INFO org.pircbotx.output.OutputRaw - JOIN #Wout_ 
[main] INFO org.pircbotx.InputParser - :tmi.twitch.tv 002 wout_ :Your host is tmi.twitch.tv
[main] INFO org.pircbotx.InputParser - :tmi.twitch.tv 003 wout_ :This server is rather new
[main] INFO org.pircbotx.InputParser - :tmi.twitch.tv 004 wout_ :-
[main] INFO org.pircbotx.InputParser - :tmi.twitch.tv 375 wout_ :-
[main] INFO org.pircbotx.InputParser - :tmi.twitch.tv 372 wout_ :You are in a maze of twisty passages, all alike.
[main] INFO org.pircbotx.InputParser - :tmi.twitch.tv 376 wout_ :>
[main] INFO org.pircbotx.InputParser - :tmi.twitch.tv CAP * ACK :twitch.tv/membership
[main] INFO org.pircbotx.InputParser - :wout_!wout_@wout_.tmi.twitch.tv JOIN #Wout_
[main] INFO org.pircbotx.output.OutputRaw - MODE #Wout_
[main] INFO org.pircbotx.InputParser - :wout_.tmi.twitch.tv 353 wout_ = #Wout_ :wout_
[main] INFO org.pircbotx.InputParser - :wout_.tmi.twitch.tv 366 wout_ #Wout_ :End of /NAMES list
[listenerPool0-thread4] INFO org.pircbotx.output.OutputRaw - PRIVMSG #Wout_ :Hello World!

Like you can see the onJoin listener is called and the message 'Hello World' is shown in the chat.

The other listeners, onMessage and onGenericMessage are never called. I tested this with both the same user (the bot) and an other user in the same chat.

I have followed this link for the configuration: https://github.com/TheLQ/pircbotx/wiki/Twitch.tv-support

Thank you

BaronOfClubs commented 8 years ago

Adding a listener to the Configuration.Buidler via .addListener(this) fixed this for me.

hoerup commented 6 years ago

I assume that you have found a solution by now? If, not please re-open this issue.