I need help with my java project. I'm currently trying to send a message in a Skype conversation when a specific action happens.
For this, I am using the java-skype API v1.4 by taskan.
Here's my code:
try {
for (Group group : Skype.getContactList().getAllGroups()) {
if ((group.getDisplayName()).equals("Nameofthegroup")) { //Whatever the group name is
String id = group.getId();
Skype.chat(id).send(ep.getDisplayName() + " joins !");
ep.sendMessage("Die ID: "+ id);
}
}
} catch (Exception e3) {
e3.printStackTrace();
}
I've also tried:
try {
String id = Skype.getContactList().getGroup("Groupname").getId();
Skype.chat(id).send(p + "joins!");
} catch (SkypeException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
My problem is that Skype registers that a external program tries to do something, but after I allow access for Java, nothing else happens. No messages are sent.
Sorry for the late answer but assuming you haven't yet picked an answer the problem is still open.
I was trying to get groups the same way with you but unfortunately it doesn't work like this. I do not if this is API problem or just because microsoft dropped support from third party APIs some of its features not working.
I managed to work this around by searching for chats not for groups. Also it would be much easier if you just bookmark (add at favorites) the chat (group) you want to find.
Chat group = null;
for ( Chat c : Skype.getAllBookmarkedChats() ){
group = c;
}
I just have the group chat in my favorites so it is super easy to retrieve it! If you have more chats and you need a more general way to find a specific one there are also several ways to do this.
for (Chat c : Skype.getAllChats()){
c.getAllMembers();
c.getId();
c.getWindowTitle();
}
group = c;
But this would be harder. The getId() way may be look easier but I didn't manage to get it working. Don't know again if it was my problem or just the API but whatever I tried simple just didn't work. And do not forget to print your results at console to ease yourself.
In the end if you manage to get your group chat it is really easy to send a message:
group.send("Hi chat! This is java!!");
EDIT
This api works only for p2p chats. If you want to create a p2p chat you need to use the /createmoderatedchat command in any chat and it will create a new empty p2p chat. Any other group will be automatic cloud-based.
Also check this
SECOND EDIT
API is completely dead
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With