Permalink
Browse files

Updated to work with node 0.1.94

  • Loading branch information...
root authored and grantmd committed May 12, 2010
1 parent 834e021 commit a1a8f9c639b14d220efe0b2bdf8d570d3068b1cf
Showing with 17 additions and 13 deletions.
  1. +2 −2 config.template.js
  2. +5 −5 lib/irc.js
  3. +10 −6 log.js
View
@@ -1,8 +1,8 @@
-process.mixin(exports, {
+exports.config = {
host: 'localhost',
port: 6667,
user: 'nodelog',
channel: '#nodejs',
logUrl: 'http://nodejs.debuggable.com/',
logPath: 'log'
-});
+};
View
@@ -1,5 +1,5 @@
var sys = require('sys');
-var tcp = require('tcp');
+var tcp = require('net');
var irc = exports;
function bind(fn, scope) {
@@ -42,8 +42,8 @@ Client.prototype.connect = function(nick, user, real) {
connection.setEncoding(this.encoding);
connection.setTimeout(this.timeout);
connection.addListener('connect', bind(this.onConnect, this));
- connection.addListener('receive', bind(this.onReceive, this));
- connection.addListener('eof', bind(this.onEof, this));
+ connection.addListener('data', bind(this.onReceive, this));
+ connection.addListener('end', bind(this.onEof, this));
connection.addListener('timeout', bind(this.onTimeout, this));
connection.addListener('close', bind(this.onClose, this));
@@ -77,7 +77,7 @@ Client.prototype.send = function(arg1) {
sys.puts('> '+message);
message = message + "\r\n";
- this.connection.send(message, this.encoding);
+ this.connection.write(message, this.encoding);
};
Client.prototype.parse = function(message) {
@@ -157,4 +157,4 @@ Client.prototype.onClose = function() {
exports.user = function(prefix) {
return prefix.match(/:([^!]+)!/)[1]
-};
+};
View
16 log.js
@@ -1,11 +1,13 @@
-process.mixin(require('sys'));
-var config = require('./config');
+var sys = require('sys');
+var config = require('./config').config;
var irc = require('./lib/irc');
-var file = require('file');
+var fs = require('fs');
var path = require('path');
var repl = require('repl');
+sys.puts(sys.inspect(config));
+
var logFile, day;
function writeLog(text) {
var date = new Date;
@@ -17,15 +19,16 @@ function writeLog(text) {
].join('-');
if (!logFile || day !== today) {
- logFile = new file.File(path.join(config.logPath, today+'.txt'), 'a+', {encoding: 'utf8'});
+ var logFilePath = path.join(config.logPath, today+'.txt');
+ logFile = fs.createWriteStream(logFilePath, {'flags': 'a+', 'encoding': 'utf8'});
day = today;
}
var time = [
('0'+date.getHours()).substr(-2),
('0'+date.getMinutes()).substr(-2)
].join(':');
- logFile.write('['+time+'] '+text+"\n");
+ logFile.write('['+time+'] '+text+'\n');
}
var
@@ -35,6 +38,7 @@ var
client.connect(config.user);
client.addListener('001', function() {
+ sys.puts('001!');
this.send('JOIN', config.channel);
});
@@ -83,4 +87,4 @@ client.addListener('PRIVMSG', function(prefix, channel, text) {
writeLog(user+': '+text);
});
-repl.start("logbot> ");
+repl.start("logbot> ");

0 comments on commit a1a8f9c

Please sign in to comment.