Minor changes
This commit is contained in:
parent
17f7ae7961
commit
f3aee8f6cb
@ -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": {
|
||||
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
13
src/log.js
13
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user