oxbot
v0.1.6
Published
# Some usage examples
Downloads
26
Readme
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!