Sending Skype messages in Java using java-skype api by taskan

I need help in my java project. I am currently trying to send a message in a Skype chat when a specific action occurs.

For this I use java-skype API v1.4 taskan .

Here is 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 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 is registering that an external program is trying to do something, but after I allow access to Java, nothing else happens. Messages are not sent.

+7
java chat skype
source share
2 answers

Sorry for the late reply, but if you have not yet selected an answer, the problem is still open.

I tried to assemble groups the same way with you, but unfortunately this does not work. I do not want if this is an API problem or simply because microsoft has dropped support for third-party APIs , some of its functions do not work.

I managed to do this by looking for chat rooms not for groups. It would also be much easier if you just marked (added to favorites) the chat (group) that you want to find.

  Chat group = null; for ( Chat c : Skype.getAllBookmarkedChats() ){ group = c; } 

I just have group chat in my favorites, so it's very easy to get! If you have more chats and 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 that would be harder. The getId () method might look simpler, but I was not able to get it to work. I don’t know again if this was my problem or just an API, but everything I tried just simply didn’t work. And do not forget to print the results on the console to make yourself easier.

In the end, if you can get a group chat, it's really easy to send a message:

 group.send("Hi chat! This is java!!"); 

EDIT

This api only works 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 automatically cloudy.

Also check this

SECOND EDIT

API is completely dead

+4
source share

I don't know too much about the Skype API, but you can check the samples for help. If you want to send a chat message when someone sends you a chat message, you can use the autoresponder example:

 package com.skype.sample; import com.skype.ChatMessage; import com.skype.ChatMessageAdapter; import com.skype.Skype; import com.skype.SkypeException; public class AutoAnswering { public static void main(String[] args) throws Exception { Skype.setDaemon(false); // to prevent exiting from this program Skype.addChatMessageListener(new ChatMessageAdapter() { public void chatMessageReceived(ChatMessage received) throws SkypeException { if (received.getType().equals(ChatMessage.Type.SAID)) { received.getSender().send("I'm working. Please, wait a moment."); } } }); } } 

There is an undefined ep variable in your code, and I cannot give you a better answer because of this. I would make a comment asking for it, but Stack Overflow does not allow new users to comment.

0
source share

All Articles