Skip to content

DavidSM100/dcbot-cli-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dcbot-cli-js

Javascript (nodejs/deno) library to make easier DeltaChat Bot development.

Install

nodejs

pnpm install dcbot-cli

deno

deno add npm:dcbot-cli

Usage

Let's create a simple echobot, first create a file named "echobot.js" and add this code:

import BotCli from "dcbot-cli";

const bot = new BotCli("echobot");

bot.on("IncomingMsg", async (accountId, { chatId, msgId }) => {
  try {
    const msg = await bot.rpc.getMessage(accountId, msgId);
    await bot.rpc.sendMsg(accountId, chatId, { text: msg.text });
  } catch (err) {
    console.trace(err);
  }
});

bot.start();

Now add an account to the bot:

node echobot.js init dcaccount:https://nine.testrun.org/new

You can also use email and password instead of a chatmail account:

node echobot.js init username@example.com password

Now get the bot's link:

node echobot.js link

And finally run the bot:

node echobot.js serve

Now just use the bot's link to contact it in DeltaChat. It will echo back any text you send to it.

To see all commands:

node echobot.js --help

You can also check the examples folder.

This is basically a small wrapper around the official Chatmail core Npm package so you will probably want to see its Javascript API.

Development

Install dependencies

pnpm install

Build

pnpm run build

This will transpile the typescript code to javascript using tsc.

To use it in watch mode:

pnpm run dev

About

Javascript library to make easier DeltaChat Bot development

Topics

Resources

License

Stars

Watchers

Forks