A simple bot for Node.js, with plugins support
A simple bot for Node.js, with plugins support.
Via npm on Node:
npm install simplebot
Reference in your program:
var simpletbot = require'simplebot';
Create, configure and launch a bot:
var bot = simplebotcreateBot;botuseplugin1;botuseplugin2;botuseplugin3;botstart;
A plugin can:
A plugin is an object with methods:
.initialize(bot)called when the plugin is added to the bot
Your plugin code can access and use all the Node.js ecosystem. It can call these bot methods:
bot.process(msg)sending a message (simple number, string, object) to be processed by bot and its plugins, in asynchronous way
bot.emit(msg)emitting an outcoming message using the bot
Some plugins can subscribe to incoming message, or can be interested in process the outcoming messages:
bot.emitter(fn)registering a function that receives a
msgparameter for each message emitted by the bot and its plugins
bot.subscribe(fn)registering a function that receives and process a
msgparameter for each message received by the bot
See the test and samples folders for more detailed use cases.
git clone git://github.com/ajlopez/SimpleBot.gitcd SimpleBotnpm installnpm test
If you submit a pull request, please be sure to add or update corresponding
test cases, and ensure that
npm test continues to pass.