From f3aee8f6cbf74955328c3d9d6de4b5c1f1aaeef9 Mon Sep 17 00:00:00 2001 From: Mattias Erming Date: Tue, 16 Sep 2014 13:06:13 -0700 Subject: [PATCH] Minor changes --- package.json | 2 +- src/client.js | 12 +++++++++++- src/log.js | 13 +++---------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 2f3afb51..28d45bb0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "shout", "description": "A web IRC client", - "version": "0.31.0", + "version": "0.31.1", "author": "Mattias Erming", "preferGlobal": true, "bin": { diff --git a/src/client.js b/src/client.js index 8e52f12b..9ca62303 100644 --- a/src/client.js +++ b/src/client.js @@ -1,5 +1,6 @@ var _ = require("lodash"); var config = require("../config"); +var Chan = require("./models/chan"); var crypto = require("crypto"); var log = require("./log"); var net = require("net"); @@ -77,7 +78,16 @@ Client.prototype.emit = function(event, data) { if (event == "msg") { var target = this.find(data.chan); if (target) { - log.write(this, target.network, target.chan, data.msg); + var chan = target.chan.name; + if (target.chan.type == Chan.Type.LOBBY) { + chan = target.network.host; + } + log.write( + this.name, + target.network.host, + chan, + data.msg + ); } } } diff --git a/src/log.js b/src/log.js index e4c2ecd6..335898a0 100644 --- a/src/log.js +++ b/src/log.js @@ -5,14 +5,8 @@ var moment = require("moment"); var Helper = require("./helper"); module.exports = { - write: function(client, network, chan, msg) { - var path = Helper.resolveHomePath( - "users", - client.name, - "logs", - network.host - ); - + write: function(user, network, chan, msg) { + var path = Helper.resolveHomePath("users", user, "logs", network); try { mkdirp.sync(path); } catch(e) { @@ -23,7 +17,6 @@ module.exports = { var tz = (config.logs || {}).timezone || "UTC+00:00"; var time = moment().zone(tz).format(format); - var name = chan.type == "lobby" ? network.host : chan.name; var line = "[" + time + "] "; if (msg.type == "message") { @@ -41,7 +34,7 @@ module.exports = { try { fs.appendFile( - path + "/" + name + ".log", + path + "/" + chan + ".log", line + "\n" ); } catch(e) {