Giter Club home page Giter Club logo

javaskype's Introduction

JavaSkype

Recent changes

  • Now supports Microsoft accounts (#24)

Introduction

JavaSkype is a lightweight and comprehensive API for Skype, using the MSNP24 protocol, and Java 8.

This API lets you:

  • Send and receive private Skype messages
  • Send and receive group chat Skype messages
  • Send, receive, accept, and deny friend requests
  • Get your contact list, know your contacts presence, and change yours
  • Add/remove users to a group
  • Block and unblock contacts
  • Get information about your contacts, such as their name, and their avatar

Install

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>

Quick example

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();

Documentation

The main entry points are :

  • the Skype object
  • the listeners you can put on the Skype object
  • the User and Group objects you get from Skype or from the listeners

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.

Building

Simply run mvn install.

Misceallenous

Tech

JavaSkype uses a very small set of libraries in order to run:

  • json - Parse JSON responses from the Skype API
  • JSoup - A lightweight and powerful library to parse HTML documents
  • JUnit - The famous testing library

Several libraries have been used during the making of this library:

  • skylogin - I originally used this library via JNI but I've rewritten it in Java in UicConnector.java
  • pyskype - I've used this library to understand how to make a MSNP24 client
  • msndevs-wiki - This wiki has helped me understand the MSNP24 protocol

License

MIT

javaskype's People

Contributors

delthas avatar metasonic avatar fabiodepin avatar formatq avatar ducc avatar haroflow avatar emersion avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.