Creates a new account associated with the token specified token
. For more information about tick_rate
, see account.tick_rate
Fetches a new chat token from the specified pass.
Fired whenever a message is received on this account.
Destroys this account. This calls destroy
on the agent
and stops the tick mechanism.
You must call this function before exiting. Otherwise, the tick mechanism will always keep the event loop busy, and the node process will never exit.
- Returns: <Promise<string[]>>
Fetch the userdata for this account. The data will be stored in account.userData
, the usernames in account.users
. The Promise resolves to the new value of account.users
.
usernames
<string[]> The usernames to return history for. Default:account.users
before
<Date> The latest point in time for which a message may be returned. Default:Date.now()
- Returns: <Promise<Object[]>>
Get the chat history of this account.
Get a specific user. If the user does not exist on this account, this method returns null
.
Note: This function performs no update checks and works solely off of the value of account.users
. It is thus recommended to call account.fetchUsers()
before calling this method.
endpoint
<string> The server endpoint to send the request to.data
<Object> The data to include in the request. Default:{}
- Returns: <Promise<Object>>
Send a request on behalf of this account. The account's agent and token will be automatically used/added for/to the request. The Promise returned resolves with the body of the reply.
sender
<string> The user to send the message fromchannel
<string> The channel to send the message tomessage
<string> The message content- Returns: <Promise<boolean>> The value of
ok
in the reply
Send a message to a channel. Acts like chats.send
ingame. The message may be looped back in a [message
] event(#eventmessage).
sender
<string> The user to send the tell fromto
<string> the user to send the tell to.message
<string> The message content- Returns: <Promise<boolean>> The value of
ok
in the reply
Send a tell to a user. Acts like chats.tell
ingame. The message may be looped back in a message
event.
Perform a tick for this account. User code should rarely, if ever, call this function.
The new tick is scheduled after this method completes.
The agent this account uses for outgoing requests. This agent is created with {keepAlive: true}
.
The last time a tick completed, but before the respective events are fired.
The timeout of the next tick. May be stale (used up) or null
if tick_rate
is Infinity
.
The amount of milliseconds delay between ticks. Should be above 800 and never below 700 (unless you enjoy getting errors about polling too fast). Takes effect on the next tick.
The token for this account.
The user data for this account. Filled by account.fetchUsers
.
The usernames for this account. Filled by account.fetchUsers
.
message
<Message> The message itself
Fired whenever a message is received for this user.
before
<Date> The latest point in time for which a message may be returned. Default:Date.now()
- Returns: <Promise<Object[]>>
Get the chat history of this user.
channel
<string> The channel to send the message tomessage
<string> The message content- Returns: <Promise<boolean>> The value of
ok
in the reply
Send a message to a channel. Acts like chats.send
ingame. The message may be looped back in a message
event.
to
<string> the user to send the tell to.message
<string> The message content- Returns: <Promise<boolean>> The value of
ok
in the reply
Send a tell to a user. Acts like chats.tell
ingame. The message may be looped back in a message
event.
The account this user is associated with.
The name of this user.
Represents a message received from the server.
If this message was received from a channel, the channel name. Otherwise, null
.
The content of this message.
Whether this message was sent from a user associated with this account. This indicates a possible loopback message or you sending messages ingame.
The name of the user who sent this message.
If this is a tell, the name of the user to which this tell was sent. Otherwise, null
.
The "special type" of this message, if any. Currently, there are only two types: "join"
for channel join messages and "leave"
for channel leave messages.
An object used for various configuration. Contains the following properties:
- <string> Default:
"www.hackmud.com"
The address of the server this wrapper talks to. Only change if you know what you are doing.
- <boolean> Default:
true
Whether to require a secure TLS connection while talking to the server. Only set to false
if you know what you are doing.