hackmud-chat-api
An easy-to-use hackmud Chat API module.
Installation
Latest NPM release (recommended): npm @skiilaa/install hackmud-chat-api
Latest GitHub version: npm install moriczgergo/hackmud-chat-api
Usage
var Hackmud = ; var chat = "token or chat_pass";console;console; chat;
Docs
Message
id
Unique message ID provided by the API.
t
Unix timestamp in milliseconds.
from_user
The user who sent the message.
to_user
The user who received the message.
msg
The message's text. (with color codes)
channel
Optional, only present if the message was sent in a channel, if the message wasn't a tell.
Client
new Client(auth)
Parameters:
auth
: A token or a chat_pass.
Initializes the client.
Example:
var chat = "ghwef";
subscribe(handler, users)
Params:
handler
: A callback that receives messages.- 1st param: Array of messages.
users
: Array of users to listen with. Optional.
Returns: Index of listener. You'll need this if you want to unsubscribe.
Example:
var handlerIndex = chat;
unsubscribe(index)
Params:
index
: Index of handler to unsubscribe.
Example:
chat;
send(username, channel, msg)
Params:
username
: Username to send message with.channel
: Channel to send message to.msg
: Message to send.
Returns: null or error, if there was one.
Example:
var err = chat;if err console;
tell(username, tell, msg)
Params:
username
: Username to send message with.tell
˙: Username to send message to.msg
: Message to send.
Returns: null or error, if there was one.
Example:
var err = chat;if err console;
users
Array of users.
channels
An object. The keys are usernames, and the values are arrays of channel names that the user has joined.
Example:
me: "0000" "town" "CHOICE_EPSILON_2" my_bot: "0000"
token
The token, either the one passed to the constructor, or the one generated from chat_pass.