Auties00 / Cobalt

Standalone unofficial fully-featured Whatsapp Web and Mobile API for Java and Kotlin
MIT License
616 stars 180 forks source link

@RegisterListener not working #378

Closed PinkyFabian96 closed 3 months ago

PinkyFabian96 commented 10 months ago

Hello, when using the @RegisterListener annotation, it doesn't detect the listening events when I create a new instance of WhatsApp and register myself.

this is my class that implements the listener:

` import it.auties.whatsapp.api.Whatsapp; import it.auties.whatsapp.listener.RegisterListener; import it.auties.whatsapp.listener.Listener;

import it.auties.whatsapp.model.info.MessageInfo; import it.auties.whatsapp.model.message.standard.TextMessage;

@RegisterListener // Automatically registers this listener public class MyListener implements Listener {

@Override
public void onLoggedIn( Whatsapp whatsapp ) {
    System.out.println("Se conecto correctamente desde la clase MyListener ");
}

@Override
public void onNewMessage(Whatsapp whatsapp, MessageInfo info, boolean offline) {
    System.out.println("Entro un nuevo mensaje");
    System.out.println( info.message().content() );
}

} `

class where I create the WhatsApp instance to register:

` public class WhatsAppMain {

@PostConstruct
public void whatsAppInit( )  {
    String uuid = "sessionFabian";
    WebOptionsBuilder webOptionsBuilder = Whatsapp.webBuilder().newConnection(uuid).autodetectListeners(true);
    ContactJid recipient = ContactJid.of( "59********" );
    webOptionsBuilder.unregistered(qr -> {

        try {
            File filePath = onQrCode( qr );

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    })
    .connect().join();
}

` If I use the .addListener(new ClassListener()) method, it works correctly when registering, but not when I use the annotation, could you lend me a hand, thank you!

imJohnYeager commented 10 months ago

Olá, poderia entrar em contato comigo? um pode ajudar ao outro.

Auties00 commented 6 months ago

Can anyone provide a reproducible example of this issue?

Auties00 commented 3 months ago

Fixed in 0.0.4