Skip to content

Commit

Permalink
Merged hotfix/readme into master
Browse files Browse the repository at this point in the history
  • Loading branch information
lenis0012 committed Nov 7, 2016
2 parents ffbfdea + d9b62ca commit fb3312d
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
Chatango Java API
=================
Chatango-Java-API is a library written for simplified interaction with the chat service Chatango.com
Version 1.1 aims to allow you to effortlessly retrieve and send data to chatango, providing data models for improved structure.
As of right now, the API is in the process of being rewritten under the "develop" branch.

### Features
- WebSocket and flash support
- Room & PM's
- Powerful credentials system
- Create new accounts
- Logging
- Models for
- Badges
- Channels
- Fonts
- Friends
- Messages
- Colors
- Users
- Event-based handler system
- Json config

### Installation
To install Chatango-Java-API v1.1, I suggest you use maven.
```xml
<dependency>
<groupId>com.lenis0012.chatango</groupId>
<artifactId>chatango-java-api</artifactId>
<version>1.1</version>
<scope>system</scope>
<systemPath>${project.baseDir}/lib/chatango-java-api.jar</systemPath>
</dependency>
```
Be sure to download the api to `lib/chatango-java-api.jar`
The download can be found under the releases tab

### Usage
To connect to a room and interact with it, you should simple call ChatangoAPI.createBot
```java
import com.lenis0012.chatango.bot.engine.Engine;
import com.lenis0012.chatango.bot.ChatangoAPI;
import com.lenis0012.chatango.bot.api.Message;
import java.util.Arrays;

public class MyChatangoApp {
public void main(String[] args) {
// Configure
Engine bot = ChatangoAPI.createBot("username", "password");
bot.init(Arrays.asList("myroom"));

// Connect
bot.start();

// Hello world
Message hello = new Message("Hello world!");
bot.getRoom("myroom").message(hello);
}
}
```
Congratulations, you are now connected to chatango.
Let's make a simple echo client, returning each message being sent.
```java
import com.lenis0012.chatango.bot.engine.Engine;
import com.lenis0012.chatango.bot.ChatangoAPI;
import com.lenis0012.chatango.bot.api.Message;
import com.lenis0012.chatango.bot.api.EventListener;
import com.lenis0012.chatango.bot.events.MessageReceiveEvent;
import java.util.Arrays;

public class MyEchoClient implements EventListener {
public void setup(Engine engine) {
ChatangoAPI.getLogger().info("Setting up echo client!");
engine.getRoom("myroom").getEventManager().addListener(this);
}

public void onMessage(MessageReceiveEvent event) {
Message response = new Message(event.getMessage().getText());
event.getRoom().message(response);
}
}
```
That's it, simply call EchoClient.setup from your MyChatangoApp class and you are all set.
For the rest of the features, you'll have to play around and see for yourself.

### Contribute
Switch to "develop" branch for more information

0 comments on commit fb3312d

Please sign in to comment.