Javascript (nodejs/deno) library to make easier DeltaChat Bot development.
pnpm install dcbot-clideno add npm:dcbot-cliLet'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/newYou can also use email and password instead of a chatmail account:
node echobot.js init username@example.com passwordNow get the bot's link:
node echobot.js linkAnd finally run the bot:
node echobot.js serveNow 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 --helpYou 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.
pnpm installpnpm run buildThis will transpile the typescript code to javascript using tsc.
To use it in watch mode:
pnpm run dev