|
| 1 | +Chatango Java API |
| 2 | +================= |
| 3 | +Chatango-Java-API is a library written for simplified interaction with the chat service Chatango.com |
| 4 | +Version 1.1 aims to allow you to effortlessly retrieve and send data to chatango, providing data models for improved structure. |
| 5 | +As of right now, the API is in the process of being rewritten under the "develop" branch. |
| 6 | + |
| 7 | +### Features |
| 8 | +- WebSocket and flash support |
| 9 | +- Room & PM's |
| 10 | +- Powerful credentials system |
| 11 | +- Create new accounts |
| 12 | +- Logging |
| 13 | +- Models for |
| 14 | + - Badges |
| 15 | + - Channels |
| 16 | + - Fonts |
| 17 | + - Friends |
| 18 | + - Messages |
| 19 | + - Colors |
| 20 | + - Users |
| 21 | +- Event-based handler system |
| 22 | +- Json config |
| 23 | + |
| 24 | +### Installation |
| 25 | +To install Chatango-Java-API v1.1, I suggest you use maven. |
| 26 | +```xml |
| 27 | +<dependency> |
| 28 | + <groupId>com.lenis0012.chatango</groupId> |
| 29 | + <artifactId>chatango-java-api</artifactId> |
| 30 | + <version>1.1</version> |
| 31 | + <scope>system</scope> |
| 32 | + <systemPath>${project.baseDir}/lib/chatango-java-api.jar</systemPath> |
| 33 | +</dependency> |
| 34 | +``` |
| 35 | +Be sure to download the api to `lib/chatango-java-api.jar` |
| 36 | +The download can be found under the releases tab |
| 37 | + |
| 38 | +### Usage |
| 39 | +To connect to a room and interact with it, you should simple call ChatangoAPI.createBot |
| 40 | +```java |
| 41 | +import com.lenis0012.chatango.bot.engine.Engine; |
| 42 | +import com.lenis0012.chatango.bot.ChatangoAPI; |
| 43 | +import com.lenis0012.chatango.bot.api.Message; |
| 44 | +import java.util.Arrays; |
| 45 | + |
| 46 | +public class MyChatangoApp { |
| 47 | + public void main(String[] args) { |
| 48 | + // Configure |
| 49 | + Engine bot = ChatangoAPI.createBot("username", "password"); |
| 50 | + bot.init(Arrays.asList("myroom")); |
| 51 | + |
| 52 | + // Connect |
| 53 | + bot.start(); |
| 54 | + |
| 55 | + // Hello world |
| 56 | + Message hello = new Message("Hello world!"); |
| 57 | + bot.getRoom("myroom").message(hello); |
| 58 | + } |
| 59 | +} |
| 60 | +``` |
| 61 | +Congratulations, you are now connected to chatango. |
| 62 | +Let's make a simple echo client, returning each message being sent. |
| 63 | +```java |
| 64 | +import com.lenis0012.chatango.bot.engine.Engine; |
| 65 | +import com.lenis0012.chatango.bot.ChatangoAPI; |
| 66 | +import com.lenis0012.chatango.bot.api.Message; |
| 67 | +import com.lenis0012.chatango.bot.api.EventListener; |
| 68 | +import com.lenis0012.chatango.bot.events.MessageReceiveEvent; |
| 69 | +import java.util.Arrays; |
| 70 | + |
| 71 | +public class MyEchoClient implements EventListener { |
| 72 | + public void setup(Engine engine) { |
| 73 | + ChatangoAPI.getLogger().info("Setting up echo client!"); |
| 74 | + engine.getRoom("myroom").getEventManager().addListener(this); |
| 75 | + } |
| 76 | + |
| 77 | + public void onMessage(MessageReceiveEvent event) { |
| 78 | + Message response = new Message(event.getMessage().getText()); |
| 79 | + event.getRoom().message(response); |
| 80 | + } |
| 81 | +} |
| 82 | +``` |
| 83 | +That's it, simply call EchoClient.setup from your MyChatangoApp class and you are all set. |
| 84 | +For the rest of the features, you'll have to play around and see for yourself. |
| 85 | + |
| 86 | +### Contribute |
| 87 | +Switch to "develop" branch for more information |
0 commit comments