JavaScript
The JavaScript client, @veilmesh/bot. Node 18 or later, no dependencies (an ES module).
npm install @veilmesh/botAn echo bot
import { Client } from "@veilmesh/bot";
const bot = await Client.fromTokenFile("token.json");
await bot.setCommands([{ name: "echo", description: "Repeat the text", args: "TEXT" }]);
await bot.skipOld();
for await (const msg of bot.messages()) {
const t = msg.text.trim();
if (t.toLowerCase() === "ping") await bot.reply(msg, "pong");
else if (t.startsWith("/echo ")) await bot.reply(msg, t.slice(6));
}messages() runs forever and reconnects while the daemon is away (1 to 30 seconds between tries); a refused token ends it with an error. Pass { reconnect: false } to stop at the first loss.
The client
new Client(token, { url, timeoutMs }), orawait Client.fromTokenFile(path, options). Loopback addresses only; the token is a private field and never appears inJSON.stringifyor errors.me(),groups().messages(wait = 30, { reconnect })— an async iterator of{ group, id, author, text, sentAt, file, seq }.events(wait),skipOld(),cursor,missed.send(group, text, replyTo),reply(msg, text),sendFile(group, path, caption),react(group, message, emoji),leave(group).commands(),setCommands(list).
Errors are ApiError with status (0: not reachable). Like the other clients, it checks the daemon's proof (/v1/hello) before the token goes out.