SimpleBot
A simple bot for Node.js, with plugins support.
Installation
Via npm on Node:
npm install simplebot
Usage
Reference in your program:
var simpletbot = ;
Create, configure and launch a bot:
var bot = simplebot; bot;bot;bot; botstart;
A plugin can:
- Produce message to be processed by the bot and its plugins
- Emit outcoming message using the bot
- Subscribe to incoming message to the bot
Writing a plugin
A plugin is an object with methods:
.initialize(bot)
called when the plugin is added to the bot.start()
called whenbot.start()
is called.stop()
called whenbot.stop()
is called
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 waybot.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 amsg
parameter for each message emitted by the bot and its pluginsbot.subscribe(fn)
registering a function that receives and process amsg
parameter for each message received by the bot
See the test and samples folders for more detailed use cases.
Development
git clone git://github.com/ajlopez/SimpleBot.git
cd SimpleBot
npm install
npm test
Samples
- Primes a prime number detector
License
MIT
Versions
- 0.0.1: Published
Contribution
Feel free to file issues and submit pull requests � contributions are welcome<
If you submit a pull request, please be sure to add or update corresponding
test cases, and ensure that npm test
continues to pass.