msgroom-bot-api v2.0.0
Certainly! Here's an updated version of the README file that includes the description of the endpoints provided by the dashboard:
msgroom-bot-api Module
The msgroom-bot-api module provides a class for interacting with a bot through a client. It allows you to connect to a server, send messages, change the bot's name, and manage the bot's dashboard.
Installation
To use the msgroom-bot-api module, you need to have Node.js installed. You can then install the module using npm or yarn:
npm install msgroom-bot-apior
yarn add msgroom-bot-apiUsage
import Bot from 'msgroom-bot-api';
// Create a new instance of the Bot
const bot = new Bot();
// Connect to the bot server
bot.connect('BotUser', 'APIKey').then(() => {
// Connected successfully, perform actions
bot.send('Hello, bot!');
bot.setName('NewBotName');
}).catch((error) => {
// Error occurred during connection
console.error('Error connecting to the bot:', error);
});API
command(cmd,func)
Creates a command in the bot.
cmd(string) : The command name including the prefixfunc(function) : The function for the command The arguments passed tofunc:- first argument - args of the command
- second argument - the message event
connect(nick, apikey, url)
Connects the bot client to the server.
nick(string): The username or nickname of the bot.apikey(string): The API key for authentication.url(string | URL): (Optional) The URL of the server to connect to. Defaults towss://windows96.net:4096.
Returns a promise that resolves when the connection is successful or rejects with an error if there is an issue.
send(msg)
Sends a message from the bot client to the server.
msg(string): The message content to send.
setName(nick)
Changes the bot's name to the specified value.
nick(string): The new name for the bot.
disconnect()
Disconnects the bot client from the server.
dashboard(rootresponse, authkey)
Starts the bot's admin dashboard on an Express server.
rootresponse(string): The response for the root endpoint ("/").authkey(string): (Optional) The authentication key for accessing the dashboard. Defaults to a random value.
The dashboard provides the following endpoints:
/(GET): Renders the root response provided in therootresponseparameter./chat/sendmessage(GET): Accepts a query parametermessageto send a message from the bot. Requires authentication using theauthkeyparameter./chat/name(GET): Accepts a query parameternameto change the bot's name. Requires authentication using theauthkeyparameter./bot/disconnect(GET): Disconnects the bot from the server. Requires authentication using theauthkeyparameter./bot/connect(GET): Reconnects the bot to the server with the previous connection status. Requires authentication using theauthkeyparameter./bot/eval(GET): Accepts a query parametercodeto evaluate and execute JavaScript code on the bot. Requires authentication using theauthkeyparameter./bot/constatus(GET): Retrieves the connection preferences of the bot. Requires authentication using theauthkeyparameter.
username
The bot's user name
SOCKET
The Websocket connection to the msgroom server
userId
The bot's userID
constatus
The bot's connection preferences
app
The Express app for dashboards
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request on the GitHub repository.
License
This module is released under the MIT License.