From b42c93a7a712beea4fefca9785cf776e93c85e65 Mon Sep 17 00:00:00 2001 From: Neel Kamath Date: Mon, 14 May 2018 14:19:29 +0530 Subject: Add initial connection documentation --- DOCUMENTATION.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 1b797f3..4fa9055 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -1,8 +1,17 @@ -You can programmatically access hack.chat using the following commands. +You can programmatically access hack.chat using the following commands via a websocket. To prevent getting disconnected, ping the server every 50 seconds. A list of wrappers written for accessing hack.chat can be found [here](https://github.com/hack-chat/3rd-party-software-list#libraries). -hack.chat has three permission levels. When you access a command, hack.chat automatically knows your permission level from your trip code. The lowest permission level is `core`. `mod` is above `core`, so it can access `core` commands in addition to `mod` commands. `admin` is similarly above `mod`. +The commands are to be sent through a websocket to the URL `wss://hack.chat/chat-ws` (everything sent and received are `string`s). If you are sending messages locally or to another domain, replace 'hack.chat' with the respective domain. If you're running your own instance of hack.chat, you can retain backwards-compatibility in order to ensure that software created for the main server will work on yours too. + +All commands sent must be JSON objects with the command specified in the `"cmd"` key. For example: +```json +{ + "cmd": "join", + "channel": "programming", + "nick": "johndoe#fag" +} +``` -The commands are to be sent through a websocket to the URL wss://hack.chat/chat-ws (everything sent and received are `string`s). If you are sending messages locally or to another domain, replace 'hack.chat' with that domain. If you're running your own instance of hack.chat, you can retain backwards-compatibility in order to ensure that software created for the main server will work on yours too. +hack.chat has three permission levels. When you access a command, hack.chat automatically knows your permission level from your trip code. The lowest permission level is `core`. `mod` is above `core`, so it can access `core` commands in addition to `mod` commands. `admin` is similarly above `mod`. # `core` -- cgit v1.2.1