GithubHelp home page GithubHelp logo

roughnecks / deltachat-node-bot-base Goto Github PK

View Code? Open in Web Editor NEW

This project forked from deltachat-bot/deltachat-node-bot-base

0.0 0.0 0.0 21 KB

A simple NodeJS library for building Delta Chat bots.

JavaScript 100.00%

deltachat-node-bot-base's Introduction

deltachat-node-bot-base

A simple library for building Delta Chat bots.

Technicaly its a small abstraction layer over deltachat-node that does the setup/boilerplate for you.

For further information on DeltaChat bots see https://bots.delta.chat/.

Prerequisites

To build a bot with this library you need to have NodeJS >= 7.6 and NPM installed. Get those from your system's package manager. E.g. on Debian/Ubuntu-based systems: apt install npm.

The bot just needs an email-account that it can reach via IMAP and SMTP.

Installation

Install via npm from the repository:

npm install --save git://github.com/deltachat-bot/deltachat-node-bot-base

Configuration

Configure the bot by writing its email-address and password into config/local.json like this:

{
  "email_address": "[email protected]",
  "email_password": "secretandsecure"
}

Usage

Here's some example code that gives you an idea:

const { deltachat, log } = require('deltachat-node-bot-base')

// Start the deltachat core engine and handle incoming messages.
deltachat.start((chat, message) => {
  const messageText = message.getText()
  log(`Received a message for chat ${chat.getName()}: ${messageText}`)

  if (chat.isSingle()) {
    // This is a 1-on-1 (aka "single") chat.
    // Reply by quoting the same text.
    deltachat.sendMessage(chat.getId(), `You said: ${messageText}`)
  } else if (messageText.match(/^bot[:, ]+/i)) {
    // Reply to a group chat only if the message starts with "Bot".
    const contact = deltachat.getContact(message.getFromId())
    const displayName = contact.getDisplayName()
    deltachat.sendMessage(chat.getId(), `${displayName} said: ${messageText}`)
  }
})

deltachat-node-bot-base's People

Contributors

pabzm avatar simon-laux avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.