Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 67be50f986b5b0b5dff33e648e36b46a2fdacf34 0 parents
@Soarez authored
2  .gitignore
@@ -0,0 +1,2 @@
+node_modules
+config.json
13 README
@@ -0,0 +1,13 @@
+Rulio, a Barebones irc bot.
+
+Before running, run npm install and copy config.json.example to config.json (this is '.gitignore'd).
+
+Rulio works with modules. Modules should export a function with only one argument, an instace of node-irc Client. Check the node-irc API http://node-irc.readthedocs.org/en/latest/API.html.
+
+Here is a module that echos private messages:
+
+module.exports = exports = function(client) {
+ client.addListener('pm', function (nick, text) {
+ client.say(nick, text);
+ });
+};
29 config.json.example
@@ -0,0 +1,29 @@
+{
+ "nick": "ruliobot",
+ "password": "password_here",
+ "server": "irc.freenode.net",
+ "connectRetryCount": 3,
+ "client": {
+ "userName": "nodebot",
+ "realName": "nodeJS IRC client",
+ "port": 6667,
+ "debug": true,
+ "showErrors": true,
+ "autoRejoin": true,
+ "autoConnect": false,
+ "channels": [
+ "#join",
+ "#these",
+ "#channels"
+ ],
+ "secure": false,
+ "selfSigned": false,
+ "certExpired": false,
+ "floodProtection": false,
+ "floodProtectionDelay": 1000,
+ "stripColors": false
+ },
+ "modules": [
+
+ ]
+}
14 package.json
@@ -0,0 +1,14 @@
+{
+ "name": "rulio",
+ "description": "Barebones irc bot",
+ "version": "0.1.0",
+ "author": "Igor Soarez <igor@soarez.com>",
+ "dependencies": {
+ "irc": "~0.3.4",
+ "lodash": "~0.3.2"
+ },
+ "engines": {
+ "node": ">=0.6.9"
+ },
+ "scripts" : { "start" : "node server.js" }
+}
34 server.js
@@ -0,0 +1,34 @@
+var irc = require('irc');
+var fs = require('fs');
+
+var conf = JSON.parse(fs.readFileSync('config.json').toString());
+
+var client = new irc.Client(conf.server, conf.nick, conf.client);
+
+if (conf.password) {
+ client.addListener('notice', function (from, to, text) {
+ console.log(text);
+
+ if (text.indexOf('This nickname is registered.') != -1) {
+ client.say('NickServ', "identify " + conf.password);
+ console.log('Identifying...');
+ }
+ });
+}
+
+conf.modules.forEach(function(module) {
+ try {
+ require(module)(client);
+ } catch (e) {
+ console.log('Failed to load module %s - %s', module, e);
+ return;
+ }
+
+ console.log('Loaded module %s', module);
+});
+
+client.connect(conf.connectRetryCount, function() {
+ console.log('Connection established.');
+});
+
+console.log('Connecting to %s...', conf.server);
Please sign in to comment.
Something went wrong with that request. Please try again.