@vex-chat/libvex

0.20.9 • Public • Published

libvex-js

build

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();

Readme

Keywords

none

Package Sidebar

Install

npm i @vex-chat/libvex

Weekly Downloads

0

Version

0.20.9

License

AGPL-3.0-or-later

Unpacked Size

276 kB

Total Files

38

Last publish

Collaborators

  • extrahash