How to Setup Automatic Chat Responses with Skype4Java

1) Create the SampleChatMessageListener.java file:

import com.skype.Chat;
import com.skype.ChatMessage;
import com.skype.ChatMessageListener;
import com.skype.SkypeException;

public final class SampleChatMessageListener implements ChatMessageListener {

  public void chatMessageReceived(final ChatMessage message) {

    try {
      final Chat chat = message.getChat();

      chat.send("Talk to the hand!");
    }

    catch (final SkypeException e) {
      e.printStackTrace();
    }

  }

  public void chatMessageSent(ChatMessage message) {
  }

}

2) Create the Sample.java file:

import com.skype.Skype;
import com.skype.SkypeException;

public final class Sample {

  public static void main(String[] args) throws SkypeException {
    Skype.addChatMessageListener(new SampleChatMessageListener());

    Skype.setDeamon(false);
  }

  private Sample() {
  }

}

3) Compile the Sample.java and SampleChatMessageListener.java files.

4) Launch the Sample class.

One thought on “How to Setup Automatic Chat Responses with Skype4Java

  1. Hi

    Add a ConnectorListener to Connector and you will receive (all) low level Skype events:

    Connector.getInstance().addConnectorListener(new ConnectorListener() {

    public void messageReceived(ConnectorMessageEvent event) {
    System.out.println(event.getMessage());
    }
    […]

    Regards,
    Pascal

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s