@vex-chat/libvex
v0.20.9
Published
Library for communicating with xchat server.
Downloads
19
Readme
libvex-js
nodejs for interfacing with xchat server. Use it for a client, a bot, whatever you'd like to connect to vex.
Documentation
Quickstart
import { Client } from "@vex-chat/libvex";
async function main() {
// generate a secret key to use, save this somewhere permanent
const privateKey = Client.generateSecretKey();
const client = new Client(privateKey);
/* the ready event is emitted when init() is finished.
you must wait until this event fires to perform
registration or login. */
client.on("ready", async () => {
// you must register once before you can log in
await client.register(Client.randomUsername());
await client.login();
});
/* The authed event fires when login() successfully completes
and the server indicates you are authorized. You must wait to
perform any operations besides register() and login() until
this occurs. */
client.on("authed", async () => {
const me = await client.users.me();
// send a message
await client.messages.send(me.userID, "Hello world!");
});
/* Outgoing and incoming messages are emitted here. */
client.on("message", (message) => {
console.log("message:", message);
});
/* you must call init() to initialize the keyring and
start the client. */
client.init();
}
main();