Skip to content

werelax/oxbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TODO: write docs

Some usage examples

From your index.js:

const config = require('config');
const botox = require('./botox');
const treeNodes = require('./modules/tree');

botox
  .setup(config.bot)
  .then(({ treeSet, server, queue, db }) => {
    const token = config.bot.telegram.token;
    const chat = botox.telegram(token);
    const tree = treeNodes(chat);
    treeSet(tree);

    console.log('* ready to go!');
  })
  .catch(console.error);

From your ./modules/tree:

const _ = require('lodash');

module.exports = chat => _.concat(
  // simple demo bot
  require('./tree.fitbot')(chat),
  require('./tree.fitbot.s1')(chat),
  require('./tree.fitbot.s2')(chat),
  require('./tree.fitbot.s3')(chat)
);

From ./modules/tree/tree.fitbot:

module.exports = (chat) => {
  return [
    {
      path: 'START',
      run: ({ state, userid, value, db }) => {
        chat.sendText(userid, 'I\'m pretty dumb');
        return state;
      },
      advance: () => 'START',
    },

  ];
};

From './config/default.json':

{
    "bot": {
        "port": 7001,
        "db": {
            "host": "localhost",
            "port": "27017",
            "database": "fitbot-bot",
            "collection": "user_states"
        },
        "telegram": {
            "interval": 500,
            "token": "YOUR-TOKEN"
        }
    }
}

Good luck!

About

(messenger/telegram/slack) bot framework, a little bit opinionanted.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published