taksan / skype-java-api

Skype API for Java, based on Skype4Java library
128 stars 60 forks source link

addContactRequestListener() #69

Closed TJFJefroy closed 7 years ago

TJFJefroy commented 8 years ago

Is it possible to add this to you can automatically accept a request over this api?

FFY00 commented 8 years ago

Of course...

// Accept Contatcs public static int accept() throws SkypeException{ Friend[] contatosAceitar = Skype.getContactList().getAllUserWaitingForAuthorization(); int aceites = 0; for(Friend aceitar : contatosAceitar){ aceitar.setAuthorized(true); aceitar.send("We'll come to my handsome program!"); aceites++; } return aceites; }

// Create a sheduler
public static final ScheduledExecutorService tarefas = Executors.newScheduledThreadPool(1);

public static void autoAccept(){
    tarefas.scheduleAtFixedRate(new Runnable() {
        public void run() {

            // call accept()
            try {
               int aceites = accept();
            } catch (SkypeException ex) {
                System.out.println("Error while accepting new contacts");
            }

        }
    }, 0, 15, TimeUnit.SECONDS);
    System.out.println("AutoAccept registered");
}

}

Just call autoAccept() in your main class :D

TJFJefroy commented 8 years ago

I did this but i was just wondering if there is any listener for this or i'm just stupid (again). But still thanks for the answer :D

FFY00 commented 8 years ago

No there's no listener :/