Official Node.js client library for Devzat plugin API

Overview

Devzat plugin API client for Node.js

This NPM package allows you to build Devzat plugins/bots with JavaScript/TypeScript. See example/index.ts for a full example of a bot made with this package.

Getting started

Install the package:

yarn add devzat

Create an instance of the client:

import Devzat from "devzat";

const plugin = new Devzat({
    address: "localhost:5556", // The address to the Devzat server's plugin API (different than the SSH port)
    token: "my-token", // The token to authenticate with the server
    name: "Demo bot" // Name of your bot (can be overridden later)
});

From there you can use various methods to send, receive, and intercept messages.

Devzat.sendMessage(message: Message): Promise<{}>

Send a message in a given room.

type Message = {
    room: string, // The room name (including the `#`) to send to
    from?: string | null, // The name of the user sending the message (defaults to the bot's name),
                          // can be set to null to not have any name attached to the message
    msg: string, // Message text (in Markdown)
    ephemeralTo?: string // Username of user to send the message to (if not set, the message will be visible by all users in the room)
}

Devzat.onMessageSend(listener: Listener, callback: (e: Event) => string | void | Promise<string> | Promise<void>): () => void

Register an event listener to fire on every message send. Returns a function to remove the listener.

type Listener = {
    middleware?: boolean, // If true, the listener can edit the user's message before it is sent
    once?: boolean, // Remove the listener after the first event
    regex?: RegExp | string // If set, the listener will only fire if the message matches the regex (doesn't include slashes or flags
}

type Event = {
    room: string,
    from: string,
    msg: string
}

Devzat.command(command: CmdDef, callback: (e: CmdInvocation) => string | void | Promise<string> | Promise<void>): () => void

Register a command to be handled by your bot. Returning a value from the callback will reply to the message.

type CmdDef = {
    name: string, // Name of the command (triggers when a message starts with it)
    argsInfo: string, // Summary of arguments (like <name>)
    info: string // Description of the command
}

type CmdInvocation = {
    room: string, // Room the command was issued in
    from: string, // User who issued the command
    args: string // Everything after the command name
}
You might also like...

A UI library by WeChat official design team, includes the most useful widgets/modules.

A UI library by WeChat official design team, includes the most useful widgets/modules.

WeUI for 小程序 为微信小程序量身设计 概述 WeUI 是一套同微信原生视觉体验一致的基础样式库,由微信官方设计团队为微信内网页和微信小程序量身设计,令用户的使用感知更加统一。包含button、cell、dialog、 progress、 toast、article、actionsheet、

Jan 4, 2023

This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js

This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js. But in most cases, I would recommend you to use something like Express in a production project for productivity purposes.

Jul 19, 2022

Deno client library for Bitwarden CLI's local REST API.

Bweno Think outside the bun 🌮 Bweno is a client library for Bitwarden CLI's local REST API. Pronounced as Spanish 'bueno', meaning 'good'. Requiremen

May 26, 2022

Improved Deno port of GramJS — a MTProto API Telegram client library.

Warning Considered as unstable. But, most of the commonly used features are working as expected. Grm Grm is an improved Deno port of GramJS, written i

Dec 31, 2022

Provides information on official divisional administrative regions of Portugal

GEO PT API Provides information on official divisional administrative regions of Portugal (based on "Carta Administrativa Oficial de Portugal, 2020",

Dec 27, 2022

official github mirror of gg-struggle

gg-struggle tl;dr gg-struggle is a program that reduces loading times by caching the Guilty Gear server responses, reducing slowdowns caused by latenc

Mar 12, 2022

official Alibaba Design system vue components snippets for visual studio code

official Alibaba Design system vue components snippets for visual studio code

Alibaba DLS Snippets for vscode Installation You can either install this extension by searching for Alibaba DLS Snippets in your vscode extensions sto

Sep 25, 2021

This is a cloned website of the official tesla page built with react js

TESLA-CLONE This is a cloned website of the official tesla page built with react js. The page has simillar sections which made duplicating these secti

Nov 7, 2022

Klecks is the official open-source release of the community-funded online painting app Kleki.

Klecks is the official open-source release of the community-funded online painting app Kleki.

Klecks (German for "splash of color", pronounced "clex") is the official open-source release of the community-funded online painting app Kleki. Klecks

Dec 27, 2022
Comments
  • 2 Errors relating to package.json not being able to be found

    2 Errors relating to package.json not being able to be found

    On Replit

    I've tried installing from yarn and npm, but always I get the same error, premature close.

    Looked this up online and it's most commonly something to do with package.json, but I couldn't find anything wrong with that, having a quick look.

    NPM log has this:

    23 silly saveTree │ └── [email protected]
    23 silly saveTree └─┬ [email protected]
    23 silly saveTree   └── [email protected]
    24 verbose stack Error: premature close
    24 verbose stack     at PassThrough.onclose (/usr/local/lib/node_modules/npm/node_modules/end-of-stream/index.js:47:67)
    24 verbose stack     at PassThrough.emit (events.js:326:22)
    24 verbose stack     at emitCloseNT (internal/streams/destroy.js:69:8)
    24 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:83:21)
    

    Locally

    Similar to premature close, as it has something to do with package.json.

    npm ERR! code ENOENT
    npm ERR! syscall open
    npm ERR! path /home/lachie/.npm/_cacache/tmp/git-cloneaPKHRl/package.json
    npm ERR! errno -2
    npm ERR! enoent ENOENT: no such file or directory, open '/home/lachie/.npm/_cacache/tmp/git-cloneaPKHRl/package.json'
    npm ERR! enoent This is related to npm not being able to find a file.
    npm ERR! enoent 
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /home/lachie/.npm/_logs/2022-04-25T03_24_34_175Z-debug-0.log
    
    opened by codingMASTER398 0
Owner
Benjamin Smith
Benjamin Smith
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
New base script bot wa by Ramdani Official, don't forget to subscribe youtube Ramdani Official.

Requirements • Installation • Thanks to • Official Group Bot • Donate Information bahasa Indonesia Ramdani Botz V17 adalah bot yang di ciptakan oleh R

Ramdani Official 22 Nov 1, 2022
Unofficial API client for the Tidbyt API. Use this client to control Tidbyt devices and integrate with other services.

Tidbyt Client for Node.js Unofficial API client for the Tidbyt API. Use this client to control Tidbyt devices and integrate with other services. Insta

Nicholas Penree 19 Dec 17, 2022
📦 Alpine JS plugin to extend the functionality of the official $persist plugin

Alpine JS Persist Extended Alpine JS magic method $storage extends the official $persist plugin to help you work with local storage ?? Example ?? <div

Mark Mead 11 Dec 28, 2022
Lightweight universal Cloudflare API client library for Node.js, Browser, and CF Workers

Cloudflare API Client Lightweight universal HTTP client for Cloudflare API based on Fetch API that works in Node.js, browser, and CF Workers environme

Kriasoft 15 Nov 13, 2022
Programmers House api official wrapper

programmershouse-wrapper Programmers House api official wrapper Install: npm install programmershouse-wrapper Example of using: With .then //importing

Raid 2 Mar 23, 2022
The official API of the OwnStore suite.

This project is part of OwnStore suite. Learn more here: https://ownstore.dev The suite contains the following projects: Website API CMS Doc Apps TWA

OwnStore 10 Aug 13, 2022
This app uses the Rick & Morty official API.

Installation First of all you have to clone this repo on your machine. git clone [ssh repo] Use the package manager NPM to install the dependencies. n

Karol Ariza G. 2 Sep 6, 2022
A UI library by WeChat official design team, includes the most useful widgets/modules in mobile web applications.

WeUI - tailor-made for WeChat web service 中文版本 Introduction WeUI is an WeChat-like UI framework officially designed by the WeChat Design Team, tailor-

Tencent 26.6k Jan 2, 2023