Getting started
Install @meshcorejs/client and run a first bot over USB, WiFi or Bluetooth.
Install
The packages depend on how the radio is connected.
npm install @meshcorejs/client serialportA first bot
Two files. main.ts connects to the radio, logs in and loads every brick found in the folders next to it.
commands/hello.ts is the first command.
const serial = new Client({
transport: new SerialTransport({ path: '/dev/ttyACM0' }), // COM3 on Windows
load: import.meta.dirname,
});import { CommandBuilder } from '@meshcorejs/client';
export default new CommandBuilder()
.setName('hello')
.setDescription('Say hello')
.setHandler((ctx) => ctx.reply(`Hello ${ctx.author.name}, I am ${ctx.client.self.name}`));
Send /hello to the bot in a DM. On a channel, send @ClubBot hello, with the name the radio advertises.
Every brick is one file with a default export, in a folder named after its kind. commands/, events/,
jobs/, permissions/, roles/ and plugins/ are scanned at login.
A radio message carries 160 UTF-8 bytes. The library refuses a message that does not fit with
MessageTooLongError instead of truncating it. See Sending messages.
Next
- Answer a command, the first guide.
- Bricks and loading to organise a bot in folders.
- Radio settings to declare the node's name and LoRa parameters.