JavaSkype is a lightweight and comprehensive API for Skype, using the MSNP24 protocol, and Java 8.
This API lets you:
JavaSkype requires Java >= 8 to run. You can get this library using Maven by adding this to your pom.xml
:
<dependencies>
<dependency>
<groupId>fr.delthas</groupId>
<artifactId>javaskype</artifactId>
<version>1.0.23</version>
</dependency>
</dependencies>
This library is Object-oriented: the main Skype object will give you User and Group objects, on which you will call methods in order to do stuff. Let's have a look at how to interact with the library.
Skype skype = new Skype("myusername", "mypassword");
try {
// If you want to report a bug, enable logging
// Skype.setDebug(path);
skype.connect(); // Will block until we're connected
} catch (IOException e) {
System.err.println("An error occured while connecting...");
e.printStackTrace();
}
// Set the error callback (will be called if any exception is thrown)
// When it is called, you'll be automatically disconnected
skype.setErrorListener(Exception::printStackTrace);
// We're connected and ready to go
// Say hello to all your contacts
for (User user : skype.getContacts()) {
user.sendMessage("Hi, " + user.getDisplayName() + ", what's up?");
}
// Better: let's say hello whenever a user connects
skype.addUserPresenceListener((user, oldPresence, presence) -> {
if (oldPresence == Presence.OFFLINE) {
user.sendMessage("Hi, " + user.getFirstname());
}
});
// Create a simple time bot
skype.addUserMessageListener((user, message) -> {
if (message.toLowerCase().contains("time")) {
user.sendMessage("The current time is: " + LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
}
});
// Invite everyone to the groups you own/are admin on
for (Group group : skype.getGroups()) {
if (group.isSelfAdmin()) {
for (User user : skype.getContacts()) {
group.addUser(user, Role.USER);
}
}
}
// Kick a user whenever he rants about Java
skype.addGroupMessageListener((group, user, message) -> {
if (message.toLowerCase().contains("java") && message.toLowerCase().contains("bad")) {
group.removeUser(user);
group.changeTopic("No Java bashing allowed here!");
}
});
// Let's disconnect
skype.disconnect();
The main entry points are :
The javadoc for the API is located at: http://www.javadoc.io/doc/fr.delthas/javaskype/
Note that this API doesn't support multithreaded calls: if you want to go for some multithreading, you will have to handle the synchronization yourself. You can however run multiple Skype accounts simultaneously, on the same or different threads.
Simply run mvn install
.
JavaSkype uses a very small set of libraries in order to run:
Several libraries have been used during the making of this library:
MIT