Redo channel logs
This commit is contained in:
parent
87b40b679a
commit
3bebc34e21
9 changed files with 140 additions and 152 deletions
|
|
@ -63,7 +63,6 @@ function Channel(name) {
|
|||
exceedmaxlength: 2, // Add a video longer than the maximum length set
|
||||
addnontemp: 2, // Add a permanent video to the playlist
|
||||
settemp: 2, // Toggle temporary status of a playlist item
|
||||
playlistgeturl: 1.5, // TODO is this even used?
|
||||
playlistshuffle: 2, // Shuffle the playlist
|
||||
playlistclear: 2, // Clear the playlist
|
||||
pollctl: 1.5, // Open/close polls
|
||||
|
|
@ -224,7 +223,7 @@ Channel.prototype.loadState = function () {
|
|||
}
|
||||
|
||||
try {
|
||||
self.logger.log("*** Loading channel state");
|
||||
self.logger.log("[init] Loading channel state from disk");
|
||||
data = JSON.parse(data);
|
||||
|
||||
// Load the playlist
|
||||
|
|
@ -305,6 +304,8 @@ Channel.prototype.saveState = function () {
|
|||
return;
|
||||
}
|
||||
|
||||
self.logger.log("[init] Saving channel state to disk");
|
||||
|
||||
var filters = self.filters.map(function (f) {
|
||||
return f.pack();
|
||||
});
|
||||
|
|
@ -562,7 +563,7 @@ Channel.prototype.join = function (user) {
|
|||
self.sendMotd([user]);
|
||||
self.sendDrinkCount([user]);
|
||||
|
||||
self.logger.log("+++ " + user.ip + " joined");
|
||||
self.logger.log("[login] " + user.ip + " joined");
|
||||
Logger.syslog.log(user.ip + " joined channel " + self.name);
|
||||
};
|
||||
|
||||
|
|
@ -620,7 +621,7 @@ Channel.prototype.part = function (user) {
|
|||
self.sendUserLeave(self.users, user);
|
||||
}
|
||||
|
||||
self.logger.log("--- " + user.ip + " (" + user.name + ") left");
|
||||
self.logger.log("[login] " + user.ip + " (" + user.name + ") left");
|
||||
if (self.users.length === 0) {
|
||||
self.emit("empty");
|
||||
return;
|
||||
|
|
@ -733,7 +734,7 @@ Channel.prototype.handleNameBan = function (actor, name, reason) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
self.logger.log("*** " + actor.name + " namebanned " + name);
|
||||
self.logger.log("[mod] " + actor.name + " namebanned " + name);
|
||||
self.sendModMessage(actor.name + " banned " + name, self.permissions.ban);
|
||||
|
||||
db.channels.isNameBanned(self.name, name, function (err, banned) {
|
||||
|
|
@ -799,7 +800,7 @@ Channel.prototype.sendUnban = function (users, data) {
|
|||
u.socket.emit("banlistRemove", data);
|
||||
}
|
||||
});
|
||||
self.logger.log("*** " + data.actor + " unbanned " + data.name);
|
||||
self.logger.log("[mod] " + data.actor + " unbanned " + data.name);
|
||||
self.sendModMessage(data.actor + " unbanned " + data.name, self.permissions.ban);
|
||||
};
|
||||
|
||||
|
|
@ -882,7 +883,7 @@ Channel.prototype.banIP = function (actor, ip, name, reason, range) {
|
|||
return;
|
||||
}
|
||||
|
||||
self.logger.log("*** " + actor.name + " banned " + ip + " (" + name + ")");
|
||||
self.logger.log("[mod] " + actor.name + " banned " + ip + " (" + name + ")");
|
||||
self.sendModMessage(actor.name + " banned " + ip + " (" + name + ")", self.permissions.ban);
|
||||
// If in the channel already, kick the banned user
|
||||
for (var i = 0; i < self.users.length; i++) {
|
||||
|
|
@ -1602,7 +1603,8 @@ Channel.prototype.addMedia = function (data, callback) {
|
|||
return;
|
||||
}
|
||||
|
||||
self.logger.log("### " + data.queueby + " queued " + media.title);
|
||||
self.logger.log("[playlist] " + data.queueby + " queued " + media.title + " (" +
|
||||
media.type + ":" + media.id + ")");
|
||||
|
||||
var item = res.item;
|
||||
var packet = {
|
||||
|
|
@ -1772,6 +1774,7 @@ Channel.prototype.handleQueuePlaylist = function (user, data) {
|
|||
for (var i = 0; i < pl.length; i++) {
|
||||
pl[i].pos = pos;
|
||||
pl[i].temp = temp;
|
||||
pl[i].queueby = user.name;
|
||||
self.addMedia(pl[i], function (err, media) {
|
||||
if (err) {
|
||||
user.socket.emit("queueFail", {
|
||||
|
|
@ -1811,7 +1814,7 @@ Channel.prototype.handleDelete = function (user, data) {
|
|||
|
||||
self.deleteMedia(data, function (err) {
|
||||
if (!err && plitem && plitem.media) {
|
||||
self.logger.log("### " + user.name + " deleted " + plitem.media.title);
|
||||
self.logger.log("[playlist] " + user.name + " deleted " + plitem.media.title);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -1929,7 +1932,7 @@ Channel.prototype.handleMove = function (user, data) {
|
|||
var afterit = self.playlist.items.find(data.after);
|
||||
var aftertitle = (afterit && afterit.media) ? afterit.media.title : "";
|
||||
if (fromit) {
|
||||
self.logger.log("### " + user.name + " moved " + fromit.media.title +
|
||||
self.logger.log("[playlist] " + user.name + " moved " + fromit.media.title +
|
||||
(aftertitle ? " after " + aftertitle : ""));
|
||||
}
|
||||
}
|
||||
|
|
@ -1962,7 +1965,7 @@ Channel.prototype.handleUncache = function (user, data) {
|
|||
return;
|
||||
}
|
||||
|
||||
self.logger.log("*** " + user.name + " deleted " + data.id + " from library");
|
||||
self.logger.log("[library] " + user.name + " deleted " + data.id + " from library");
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -1974,7 +1977,11 @@ Channel.prototype.handlePlayNext = function (user) {
|
|||
return;
|
||||
}
|
||||
|
||||
this.logger.log("### " + user.name + " skipped the video");
|
||||
var title = "";
|
||||
if (this.playlist.current && this.playlist.current.title) {
|
||||
title = " " + this.playlist.current.title;
|
||||
}
|
||||
this.logger.log("[playlist] " + user.name + " skipped" + title);
|
||||
this.playlist.next();
|
||||
};
|
||||
|
||||
|
|
@ -1990,7 +1997,12 @@ Channel.prototype.handleJumpTo = function (user, data) {
|
|||
return;
|
||||
}
|
||||
|
||||
this.logger.log("### " + user.name + " skipped the video");
|
||||
var to = this.playlist.items.find(data);
|
||||
var title = "";
|
||||
if (to != null) {
|
||||
title = " to " + to.media.title;
|
||||
}
|
||||
this.logger.log("[playlist] " + user.name + " skipped" + title);
|
||||
this.playlist.jump(data);
|
||||
};
|
||||
|
||||
|
|
@ -2012,7 +2024,7 @@ Channel.prototype.handleClear = function (user) {
|
|||
return;
|
||||
}
|
||||
|
||||
this.logger.log("### " + user.name + " cleared the playlist");
|
||||
this.logger.log("[playlist] " + user.name + " cleared the playlist");
|
||||
this.clear();
|
||||
};
|
||||
|
||||
|
|
@ -2045,7 +2057,7 @@ Channel.prototype.handleShuffle = function (user) {
|
|||
return;
|
||||
}
|
||||
|
||||
this.logger.log("### " + user.name + " shuffle the playlist");
|
||||
this.logger.log("[playlist] " + user.name + " shuffle the playlist");
|
||||
this.shuffle();
|
||||
};
|
||||
|
||||
|
|
@ -2102,7 +2114,7 @@ Channel.prototype.handleOpenPoll = function (user, data) {
|
|||
var poll = new Poll(user.name, title, opts, obscured);
|
||||
this.poll = poll;
|
||||
this.sendPoll(this.users, true);
|
||||
this.logger.log("*** " + user.name + " Opened Poll: '" + poll.title + "'");
|
||||
this.logger.log("[poll] " + user.name + " Opened Poll: '" + poll.title + "'");
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -2119,7 +2131,7 @@ Channel.prototype.handleClosePoll = function (user) {
|
|||
this.sendPollUpdate(this.users);
|
||||
}
|
||||
|
||||
this.logger.log("*** " + user.name + " closed the active poll");
|
||||
this.logger.log("[poll] " + user.name + " closed the active poll");
|
||||
this.poll = false;
|
||||
this.sendAll("closePoll");
|
||||
}
|
||||
|
|
@ -2161,7 +2173,14 @@ Channel.prototype.handleVoteskip = function (user) {
|
|||
this.voteskip = new Poll("voteskip", "voteskip", ["yes"]);
|
||||
}
|
||||
this.voteskip.vote(user.ip, 0);
|
||||
this.logger.log("### " + (user.name ? user.name : "anonymous") + " voteskipped");
|
||||
|
||||
var title = "";
|
||||
if (this.playlist.current && this.playlist.current.title) {
|
||||
title = " " + this.playlist.current.title;
|
||||
}
|
||||
|
||||
this.logger.log("[playlist] " + (user.name ? user.name : "anonymous") +
|
||||
" voteskipped" + title);
|
||||
this.checkVoteskipPass();
|
||||
};
|
||||
|
||||
|
|
@ -2184,7 +2203,12 @@ Channel.prototype.checkVoteskipPass = function () {
|
|||
var max = this.calcVoteskipMax();
|
||||
var need = Math.ceil(max * this.opts.voteskip_ratio);
|
||||
if (this.voteskip.counts[0] >= need) {
|
||||
this.logger.log("### Voteskip passed, skipping to next video");
|
||||
var title = "";
|
||||
if (this.playlist.current && this.playlist.current.title) {
|
||||
title = " " + this.playlist.current.title;
|
||||
}
|
||||
|
||||
this.logger.log("[playlist] Voteskip passed, skipping" + title);
|
||||
this.playlist.next();
|
||||
}
|
||||
|
||||
|
|
@ -2210,7 +2234,7 @@ Channel.prototype.handleSetLock = function (user, data) {
|
|||
|
||||
|
||||
data.locked = Boolean(data.locked);
|
||||
this.logger.log("*** " + user.name + " set playlist lock to " + data.locked);
|
||||
this.logger.log("[playlist] " + user.name + " set playlist lock to " + data.locked);
|
||||
this.setLock(data.locked);
|
||||
};
|
||||
|
||||
|
|
@ -2320,7 +2344,9 @@ Channel.prototype.handleUpdateFilter = function (user, f) {
|
|||
return;
|
||||
}
|
||||
|
||||
this.logger.log("%%% " + user.name + " updated filter: " + f.name);
|
||||
this.logger.log("[mod] " + user.name + " updated filter: " + f.name + " -> " +
|
||||
"s/" + f.source + "/" + f.replace + "/" + f.flags + " active: " +
|
||||
f.active);
|
||||
this.updateFilter(filter);
|
||||
};
|
||||
|
||||
|
|
@ -2356,7 +2382,7 @@ Channel.prototype.handleRemoveFilter = function (user, f) {
|
|||
return;
|
||||
}
|
||||
|
||||
this.logger.log("%%% " + user.name + " removed filter: " + f.name);
|
||||
this.logger.log("[mod] " + user.name + " removed filter: " + f.name);
|
||||
this.removeFilter(f);
|
||||
};
|
||||
|
||||
|
|
@ -2408,7 +2434,7 @@ Channel.prototype.handleSetPermissions = function (user, perms) {
|
|||
}
|
||||
}
|
||||
|
||||
this.logger.log("%%% " + user.name + " updated permissions");
|
||||
this.logger.log("[mod] " + user.name + " updated permissions");
|
||||
this.sendAll("setPermissions", this.permissions);
|
||||
};
|
||||
|
||||
|
|
@ -2520,7 +2546,7 @@ Channel.prototype.handleUpdateOptions = function (user, data) {
|
|||
this.opts.password = pw;
|
||||
}
|
||||
|
||||
this.logger.log("%%% " + user.name + " updated channel options");
|
||||
this.logger.log("[mod] " + user.name + " updated channel options");
|
||||
this.sendOpts(this.users);
|
||||
};
|
||||
|
||||
|
|
@ -2541,7 +2567,7 @@ Channel.prototype.handleSetCSS = function (user, data) {
|
|||
this.css = css;
|
||||
this.sendCSSJS(this.users);
|
||||
|
||||
this.logger.log("%%% " + user.name + " updated the channel CSS");
|
||||
this.logger.log("[mod] " + user.name + " updated the channel CSS");
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -2561,7 +2587,7 @@ Channel.prototype.handleSetJS = function (user, data) {
|
|||
this.js = js;
|
||||
this.sendCSSJS(this.users);
|
||||
|
||||
this.logger.log("%%% " + user.name + " updated the channel JS");
|
||||
this.logger.log("[mod] " + user.name + " updated the channel JS");
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -2592,7 +2618,7 @@ Channel.prototype.handleSetMotd = function (user, data) {
|
|||
var motd = data.motd.substring(0, 20000);
|
||||
|
||||
this.setMotd(motd);
|
||||
this.logger.log("%%% " + user.name + " updated the MOTD");
|
||||
this.logger.log("[mod] " + user.name + " updated the MOTD");
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -2785,7 +2811,7 @@ Channel.prototype.handleSetRank = function (user, data) {
|
|||
return;
|
||||
}
|
||||
|
||||
self.logger.log("*** " + user.name + " set " + name + "'s rank to " + rank);
|
||||
self.logger.log("[mod] " + user.name + " set " + name + "'s rank to " + rank);
|
||||
self.sendAll("setUserRank", {
|
||||
name: name,
|
||||
rank: rank
|
||||
|
|
@ -2826,7 +2852,7 @@ Channel.prototype.changeLeader = function (name) {
|
|||
|
||||
if (!name) {
|
||||
this.sendAll("setLeader", "");
|
||||
this.logger.log("*** Resuming autolead");
|
||||
this.logger.log("[playlist] Resuming autolead");
|
||||
this.playlist.lead(true);
|
||||
return;
|
||||
}
|
||||
|
|
@ -2834,7 +2860,7 @@ Channel.prototype.changeLeader = function (name) {
|
|||
for (var i = 0; i < this.users.length; i++) {
|
||||
if (this.users[i].name === name) {
|
||||
this.sendAll("setLeader", name);
|
||||
this.logger.log("*** Assigned leader: " + name);
|
||||
this.logger.log("[playlist] Assigned leader: " + name);
|
||||
this.playlist.lead(false);
|
||||
this.leader = this.users[i];
|
||||
if (this.users[i].rank < 1.5) {
|
||||
|
|
@ -2865,7 +2891,7 @@ Channel.prototype.handleChangeLeader = function (user, data) {
|
|||
}
|
||||
|
||||
this.changeLeader(data.name);
|
||||
this.logger.log("### " + user.name + " assigned leader to " + data.name);
|
||||
this.logger.log("[mod] " + user.name + " assigned leader to " + data.name);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ function handleShadowMute(chan, user, args) {
|
|||
person.meta.smuted = person.meta.muted = true;
|
||||
chan.sendUserMeta(chan.users, person, 2);
|
||||
chan.mutedUsers.add("[shadow]" + person.name.toLowerCase());
|
||||
chan.logger.log("*** " + user.name + " shadow muted " + args[0]);
|
||||
chan.logger.log("[mod] " + user.name + " shadow muted " + args[0]);
|
||||
chan.sendModMessage(user.name + " shadow muted " + args[0], 2);
|
||||
}
|
||||
}
|
||||
|
|
@ -228,7 +228,7 @@ function handleMute(chan, user, args) {
|
|||
person.meta.muted = true;
|
||||
chan.sendUserMeta(chan.users, person);
|
||||
chan.mutedUsers.add(person.name.toLowerCase());
|
||||
chan.logger.log("*** " + user.name + " muted " + args[0]);
|
||||
chan.logger.log("[mod] " + user.name + " muted " + args[0]);
|
||||
chan.sendModMessage(user.name + " muted " + args[0], 2);
|
||||
}
|
||||
}
|
||||
|
|
@ -258,7 +258,7 @@ function handleUnmute(chan, user, args) {
|
|||
chan.sendUserMeta(chan.users, person, wasSmuted ? 2 : false);
|
||||
chan.mutedUsers.remove(person.name.toLowerCase());
|
||||
chan.mutedUsers.remove("[shadow]" + person.name.toLowerCase());
|
||||
chan.logger.log("*** " + user.name + " unmuted " + args[0]);
|
||||
chan.logger.log("[mod] " + user.name + " unmuted " + args[0]);
|
||||
chan.sendModMessage(user.name + " unmuted " + args[0], 2);
|
||||
}
|
||||
}
|
||||
|
|
@ -287,7 +287,7 @@ function handleKick(chan, user, args) {
|
|||
}
|
||||
}
|
||||
if (kickee) {
|
||||
chan.logger.log("*** " + user.name + " kicked " + args[0]);
|
||||
chan.logger.log("[mod] " + user.name + " kicked " + args[0]);
|
||||
args[0] = "";
|
||||
var reason = args.join(" ");
|
||||
kickee.kick(reason);
|
||||
|
|
@ -319,7 +319,7 @@ function handleBan(chan, user, args) {
|
|||
|
||||
function handleUnban(chan, user, args) {
|
||||
if (chan.hasPermission(user, "ban") && args.length > 0) {
|
||||
chan.logger.log("*** " + user.name + " unbanned " + args[0]);
|
||||
chan.logger.log("[mod] " + user.name + " unbanned " + args[0]);
|
||||
if (args[0].match(/(\d+)\.(\d+)\.(\d+)\.(\d+)/)) {
|
||||
chan.unbanIP(user, args[0]);
|
||||
}
|
||||
|
|
@ -337,7 +337,7 @@ function handlePoll(chan, user, msg, hidden) {
|
|||
var poll = new Poll(user.name, title, args, hidden === true);
|
||||
chan.poll = poll;
|
||||
chan.sendPoll(chan.users);
|
||||
chan.logger.log("*** " + user.name + " Opened Poll: '" + poll.title + "'");
|
||||
chan.logger.log("[poll] " + user.name + " Opened Poll: '" + poll.title + "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ module.exports = {
|
|||
chan.name = res[0].name;
|
||||
chan.canonical_name = chan.name.toLowerCase();
|
||||
chan.registered = true;
|
||||
chan.logger.log("*** Loaded channel from database");
|
||||
chan.logger.log("[init] Loaded channel from database");
|
||||
callback(null, true);
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ function Playlist(chan) {
|
|||
chan.resetVideo();
|
||||
chan.sendAll("setCurrent", pl.current.uid);
|
||||
chan.sendAll("changeMedia", m.fullupdate());
|
||||
chan.logger.log("[playlist] Now playing: " + m.title + " (" + m.type + ":" + m.id +
|
||||
")");
|
||||
});
|
||||
this.on("remove", function(item) {
|
||||
if (chan.dead) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue