Skip to content
This repository
Browse code

Initial commit

  • Loading branch information...
commit 67be50f986b5b0b5dff33e648e36b46a2fdacf34 0 parents
Igor Soarez authored
2  .gitignore
... ...
@@ -0,0 +1,2 @@
  1
+node_modules
  2
+config.json
13  README
... ...
@@ -0,0 +1,13 @@
  1
+Rulio, a Barebones irc bot.
  2
+
  3
+Before running, run npm install and copy config.json.example to config.json (this is '.gitignore'd).
  4
+
  5
+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.
  6
+
  7
+Here is a module that echos private messages:
  8
+
  9
+module.exports = exports = function(client) {
  10
+  client.addListener('pm', function (nick, text) {
  11
+     client.say(nick, text);
  12
+  });
  13
+};
29  config.json.example
... ...
@@ -0,0 +1,29 @@
  1
+{
  2
+  "nick": "ruliobot",
  3
+  "password": "password_here",
  4
+  "server": "irc.freenode.net",
  5
+  "connectRetryCount": 3,
  6
+  "client": {
  7
+    "userName": "nodebot",
  8
+    "realName": "nodeJS IRC client",
  9
+    "port": 6667,
  10
+    "debug": true,
  11
+    "showErrors": true,
  12
+    "autoRejoin": true,
  13
+    "autoConnect": false,
  14
+    "channels": [
  15
+      "#join",
  16
+      "#these",
  17
+      "#channels"
  18
+    ],
  19
+    "secure": false,
  20
+    "selfSigned": false,
  21
+    "certExpired": false,
  22
+    "floodProtection": false,
  23
+    "floodProtectionDelay": 1000,
  24
+    "stripColors": false
  25
+  },
  26
+  "modules": [
  27
+    
  28
+  ]
  29
+}
14  package.json
... ...
@@ -0,0 +1,14 @@
  1
+{
  2
+  "name": "rulio",
  3
+  "description": "Barebones irc bot",
  4
+  "version": "0.1.0",
  5
+  "author": "Igor Soarez <igor@soarez.com>",
  6
+  "dependencies": {
  7
+    "irc": "~0.3.4",
  8
+    "lodash": "~0.3.2"
  9
+  },
  10
+  "engines": {
  11
+    "node": ">=0.6.9"
  12
+  },
  13
+  "scripts" : { "start" : "node server.js" }
  14
+}
34  server.js
... ...
@@ -0,0 +1,34 @@
  1
+var irc = require('irc');
  2
+var fs = require('fs');
  3
+
  4
+var conf = JSON.parse(fs.readFileSync('config.json').toString());
  5
+
  6
+var client = new irc.Client(conf.server, conf.nick, conf.client);
  7
+
  8
+if (conf.password) {
  9
+  client.addListener('notice', function (from, to, text) {
  10
+    console.log(text);
  11
+
  12
+    if (text.indexOf('This nickname is registered.') != -1) {
  13
+     client.say('NickServ', "identify " + conf.password);
  14
+     console.log('Identifying...');
  15
+    }
  16
+  });
  17
+}
  18
+
  19
+conf.modules.forEach(function(module) {
  20
+  try {
  21
+    require(module)(client);
  22
+  } catch (e) {
  23
+    console.log('Failed to load module %s - %s', module, e);
  24
+    return;
  25
+  }
  26
+  
  27
+  console.log('Loaded module %s', module);
  28
+});
  29
+
  30
+client.connect(conf.connectRetryCount, function() {
  31
+  console.log('Connection established.');
  32
+});
  33
+
  34
+console.log('Connecting to %s...', conf.server);

0 notes on commit 67be50f

Please sign in to comment.
Something went wrong with that request. Please try again.