0.1.9 • Published 2 years ago
master-bot v0.1.9
MasterBot A Node.js Bot to create a network of bots that can communicate with each other. and share contacts in a peer to peer fashion. beside executing commands, it can also be used to send messages to other bots.
Installation
npm install master-bot -s
// or
npm install master-bot -g
Usage
const MasterBot = require('master-bot');
const bot = new MasterBot({
name: 'bot1',
port: 3000,
peers: ['http://localhost:3001']
});
bot.start();
API
MasterBot
new MasterBot(options)
Creates a new instance of MasterBot.
options
Type: Object
name
Type: String
The name of the bot.
port
Type: Number
The port on which the bot will listen for incoming connections.
peers
Type: Array
An array of peers to connect to.
bot.start()
Starts the bot.
bot.stop()
Stops the bot.
bot.send(message, peer)
Sends a message to a peer.
message
Type: String
The message to send.
peer
Type: String
The peer to send the message to.
bot.on('message', (message, peer) => {})
Emitted when a message is received from a peer.
message
Type: String
The message received.