0.1.6 • Published 10 years ago

oxbot v0.1.6

Weekly downloads
4
License
ISC
Repository
github
Last release
10 years ago

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!

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.2

10 years ago