Permalink
Browse files

How-to-module instructions

  • Loading branch information...
1 parent b033442 commit ba7ffe11fc04b9c323a9174c25d7478077246502 @Soarez committed Oct 6, 2012
Showing with 28 additions and 13 deletions.
  1. +26 −6 README.md
  2. +0 −5 modules/echo.js
  3. +2 −2 package.json
View
@@ -17,26 +17,46 @@ Edit `config.json` to your needs.
## Modules
-Rulio works with modules. Modules should export a function with only one argument, an instace of [node-irc](https://github.com/martynsmith/node-irc/) Client. You should check the [API](http://node-irc.readthedocs.org/en/latest/API.html).
+Rulio works with modules. Modules should export a function with two arguments, an instace of [node-irc](https://github.com/martynsmith/node-irc/) (you should check the [API](http://node-irc.readthedocs.org/en/latest/API.html)) and an object with Rulio's configuration. Client.
+
+**Rulio modules should be [npm modules](http://howtonode.org/how-to-module).**
###### Example
-Here is a module that echos private messages. It is already in the `modules` folder.
+Here is a module that echos private messages.
+
+On dedicated folder, create a file named `echo.js` with this:
- module.exports = exports = function(client) {
+ module.exports = function(client) {
client.addListener('pm', function (nick, text) {
client.say(nick, text);
});
};
-Load it in `config.json`, by adding it to `modules`.
+Use [`npm init`](https://npmjs.org/doc/init.html) to have npm create a `package.json`, and when set `name` to `rulio-echo` and `main` to `echo.js`.
+
+Now the module can be published with `npm publish` and other rulio users could start using it by using `npm install rulio-echo`. But before publishing we want to test it, and make changes to it. So we use use [`npm link`](https://npmjs.org/doc/link.html) to debug:
+
+On the module folder:
+
+ npm link
+
+On rulio's folder:
+
+ npm link rulio-echo
+
+This way, npm will symlink the modules folder to a folder named rulio-echo inside node_modules. This way, the module can be `require()`d like any installed npm module.
+
+#### Loading modules
+
+Load it in rulio's `config.json`, by adding it to `modules`.
...
"modules": [
- "echo"
+ "rulio-echo"
]
...
## License
-MIT
+MIT
View
@@ -1,5 +0,0 @@
-module.exports = exports = function(client) {
- client.addListener('pm', function (nick, text) {
- client.say(nick, text);
- });
-};
View
@@ -1,8 +1,8 @@
{
"name": "rulio",
"description": "Barebones module based irc bot",
- "version": "0.1.0",
- "author": "Igor Soarez <igor@soarez.com>",
+ "version": "1.0.0",
+ "author": "Igor Soarez <igorsoarez@gmail.com>",
"dependencies": {
"irc": "~0.3.4",
"lodash": "~0.3.2"

0 comments on commit ba7ffe1

Please sign in to comment.