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

13,405

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

Share:
13,405

Related videos on Youtube

Stefan x
Author by

Stefan x

Updated on June 26, 2022

Comments

  • Stefan x
    Stefan x almost 2 years

    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.

  • Stefan x
    Stefan x over 9 years
    thanks but i do not need a listener. i just simply want to send the message but it do not work :(
  • Stefan x
    Stefan x about 9 years
    yes i still have the problem :) i will try this tomorrow thanks for your answer :)) hope it will work
  • Little Jacod
    Little Jacod about 9 years
    if you need more help just let me know
  • Stefan x
    Stefan x about 9 years
    yes have a problem... :) does this work for groupchats? because if i try it i get the error: NotAttachedException?
  • Little Jacod
    Little Jacod about 9 years
    yes it does! I am working it for group chats. Can you give me your code?
  • Stefan x
    Stefan x about 9 years
    Chat group = null; try { for ( Chat f : Skype.getAllBookmarkedChats() ){ group = f; group.send("Der Spieler " + ep.getDisplayName() +" hat den Server betreten"); } } catch (SkypeException u) { u.printStackTrace(); } }