Create 1.1-indev branch, list of updates in README
This commit is contained in:
parent
8ca4aa4327
commit
3f27bfdbdf
45 changed files with 16057 additions and 11847 deletions
|
|
@ -1,3 +1,42 @@
|
|||
/*
|
||||
fore.st is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
fore.st is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with fore.st. If not, see < http://www.gnu.org/licenses/ >.
|
||||
(C) 2022- by rainbownapkin, <ourforest@420blaze.it>
|
||||
|
||||
Original cytube license:
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013-2022 Calvin Montgomery
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
var ChannelModule = require("./module");
|
||||
var Flags = require("../flags");
|
||||
var fs = require("fs");
|
||||
|
|
@ -94,8 +133,9 @@ function Channel(name) {
|
|||
}, USERCOUNT_THROTTLE);
|
||||
const self = this;
|
||||
db.channels.load(this, function (err) {
|
||||
if (err && err !== "Channel is not registered") {
|
||||
self.emit("loadFail", "Failed to load channel data from the database. Please try again later.");
|
||||
if (err /*&& err !== "Channel is not registered"*/) {
|
||||
//self.emit("channelNotRegistered");
|
||||
self.emit("loadFail", "Channel not found.");
|
||||
self.setFlag(Flags.C_ERROR);
|
||||
} else {
|
||||
self.initModules();
|
||||
|
|
@ -147,7 +187,6 @@ Channel.prototype.initModules = function () {
|
|||
"./permissions" : "permissions",
|
||||
"./emotes" : "emotes",
|
||||
"./chat" : "chat",
|
||||
"./drink" : "drink",
|
||||
"./filters" : "filters",
|
||||
"./customization" : "customization",
|
||||
"./opts" : "options",
|
||||
|
|
|
|||
|
|
@ -1,3 +1,42 @@
|
|||
/*
|
||||
fore.st is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
fore.st is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with fore.st. If not, see < http://www.gnu.org/licenses/ >.
|
||||
(C) 2022- by rainbownapkin, <ourforest@420blaze.it>
|
||||
|
||||
Original cytube license:
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013-2022 Calvin Montgomery
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
var Config = require("../config");
|
||||
var XSS = require("../xss");
|
||||
var ChannelModule = require("./module");
|
||||
|
|
@ -36,18 +75,16 @@ function ChatModule(_channel) {
|
|||
this.supportsDirtyCheck = true;
|
||||
|
||||
/* Default commands */
|
||||
this.registerCommand("/me", this.handleCmdMe.bind(this));
|
||||
this.registerCommand("/sp", this.handleCmdSp.bind(this));
|
||||
this.registerCommand("/say", this.handleCmdSay.bind(this));
|
||||
this.registerCommand("/rcv", this.handleCmdSay.bind(this));
|
||||
this.registerCommand("/shout", this.handleCmdSay.bind(this));
|
||||
this.registerCommand("/clear", this.handleCmdClear.bind(this));
|
||||
this.registerCommand("/a", this.handleCmdAdminflair.bind(this));
|
||||
this.registerCommand("/afk", this.handleCmdAfk.bind(this));
|
||||
this.registerCommand("/mute", this.handleCmdMute.bind(this));
|
||||
this.registerCommand("/smute", this.handleCmdSMute.bind(this));
|
||||
this.registerCommand("/unmute", this.handleCmdUnmute.bind(this));
|
||||
this.registerCommand("/unsmute", this.handleCmdUnmute.bind(this));
|
||||
this.registerCommand("!me", this.handleCmdMe.bind(this));
|
||||
this.registerCommand("!sp", this.handleCmdSp.bind(this));
|
||||
this.registerCommand("!announce", this.handleCmdSay.bind(this));
|
||||
this.registerCommand("!clear", this.handleCmdClear.bind(this));
|
||||
this.registerCommand("!a", this.handleCmdAdminflair.bind(this));
|
||||
this.registerCommand("!afk", this.handleCmdAfk.bind(this));
|
||||
this.registerCommand("!mute", this.handleCmdMute.bind(this));
|
||||
this.registerCommand("!smute", this.handleCmdSMute.bind(this));
|
||||
this.registerCommand("!unmute", this.handleCmdUnmute.bind(this));
|
||||
this.registerCommand("!unsmute", this.handleCmdUnmute.bind(this));
|
||||
}
|
||||
|
||||
ChatModule.prototype = Object.create(ChannelModule.prototype);
|
||||
|
|
@ -320,7 +357,8 @@ ChatModule.prototype.processChatMsg = function (user, data) {
|
|||
msgobj.meta.addClass = "greentext";
|
||||
}
|
||||
|
||||
if (data.msg.indexOf("/") === 0) {
|
||||
//if (data.msg.indexOf("/") === 0) {Legacy from cytube '/' commands
|
||||
if (data.msg.indexOf("!") === 0) {
|
||||
var space = data.msg.indexOf(" ");
|
||||
var cmd;
|
||||
if (space < 0) {
|
||||
|
|
@ -455,7 +493,8 @@ ChatModule.prototype.sendMessage = function (msgobj) {
|
|||
};
|
||||
|
||||
ChatModule.prototype.registerCommand = function (cmd, cb) {
|
||||
cmd = cmd.replace(/^\//, "");
|
||||
//cmd = cmd.replace(/^\//, ""); Legacy from cytube '/' commands
|
||||
cmd = cmd.replace(/^!/, "");
|
||||
this.commandHandlers[cmd] = cb;
|
||||
};
|
||||
|
||||
|
|
@ -494,12 +533,44 @@ ChatModule.prototype.handleCmdClear = function (user, _msg, _meta) {
|
|||
if (!this.channel.modules.permissions.canClearChat(user)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var target = _msg.toLowerCase().split(" ")[1];
|
||||
var tdisp = undefined;
|
||||
var nhit = false;
|
||||
|
||||
|
||||
|
||||
if(target != null){
|
||||
for(var i = 0; i < this.channel.users.length; i++){
|
||||
if(nhit = (target === this.channel.users[i].getLowerName())){
|
||||
tdisp = this.channel.users[i].getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
target = nhit ? target : undefined;
|
||||
}
|
||||
|
||||
|
||||
this.dirty = true;
|
||||
this.buffer = [];
|
||||
this.channel.broadcastAll("clearchat", { clearedBy: user.getName() });
|
||||
this.sendModMessage(user.getName() + " cleared chat.", -1);
|
||||
this.channel.logger.log("[mod] " + user.getName() + " used /clear");
|
||||
|
||||
|
||||
this.channel.broadcastAll("clearchat", { clearedBy: user.getName(), target: tdisp });
|
||||
|
||||
if(target == null){
|
||||
this.buffer = [];
|
||||
this.sendModMessage(user.getName() + " cleared chat.", -1);
|
||||
this.channel.logger.log("[mod] " + user.getName() + " used !clear");
|
||||
}else{
|
||||
for(var x = 0; x < this.buffer.length; x++){
|
||||
if(this.buffer[x].username.toLowerCase() == target){
|
||||
//this.buffer.msg = '';
|
||||
this.buffer.splice(x,1);
|
||||
x--;
|
||||
}
|
||||
}
|
||||
this.sendModMessage(user.getName() + " cleared chats from " + tdisp + ".", -1);
|
||||
this.channel.logger.log("[mod] " + user.getName() + " cleared chats from " + tdisp + ".");
|
||||
}
|
||||
};
|
||||
|
||||
ChatModule.prototype.handleCmdAdminflair = function (user, msg, meta) {
|
||||
|
|
@ -510,7 +581,7 @@ ChatModule.prototype.handleCmdAdminflair = function (user, msg, meta) {
|
|||
args.shift();
|
||||
|
||||
var superadminflair = {
|
||||
labelclass: "label-danger",
|
||||
labelclass: "label-admin",
|
||||
icon: "glyphicon-globe"
|
||||
};
|
||||
|
||||
|
|
@ -547,7 +618,7 @@ ChatModule.prototype.handleCmdMute = function (user, msg, _meta) {
|
|||
var name = args.shift();
|
||||
if (typeof name !== "string") {
|
||||
user.socket.emit("errorMsg", {
|
||||
msg: "/mute requires a target name"
|
||||
msg: "!mute requires a target name"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
@ -564,7 +635,7 @@ ChatModule.prototype.handleCmdMute = function (user, msg, _meta) {
|
|||
|
||||
if (!target) {
|
||||
user.socket.emit("errorMsg", {
|
||||
msg: "/mute target " + name + " not present in channel."
|
||||
msg: "!mute target " + name + " not present in channel."
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
@ -572,7 +643,7 @@ ChatModule.prototype.handleCmdMute = function (user, msg, _meta) {
|
|||
if (target.account.effectiveRank >= user.account.effectiveRank
|
||||
|| target.account.globalRank > user.account.globalRank) {
|
||||
user.socket.emit("errorMsg", {
|
||||
msg: "/mute failed - " + target.getName() + " has equal or higher rank " +
|
||||
msg: "!mute failed - " + target.getName() + " has equal or higher rank " +
|
||||
"than you."
|
||||
});
|
||||
return;
|
||||
|
|
@ -597,7 +668,7 @@ ChatModule.prototype.handleCmdSMute = function (user, msg, _meta) {
|
|||
var name = args.shift();
|
||||
if (typeof name !== "string") {
|
||||
user.socket.emit("errorMsg", {
|
||||
msg: "/smute requires a target name"
|
||||
msg: "!smute requires a target name"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
@ -614,7 +685,7 @@ ChatModule.prototype.handleCmdSMute = function (user, msg, _meta) {
|
|||
|
||||
if (!target) {
|
||||
user.socket.emit("errorMsg", {
|
||||
msg: "/smute target " + name + " not present in channel."
|
||||
msg: "!smute target " + name + " not present in channel."
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
@ -622,7 +693,7 @@ ChatModule.prototype.handleCmdSMute = function (user, msg, _meta) {
|
|||
if (target.account.effectiveRank >= user.account.effectiveRank
|
||||
|| target.account.globalRank > user.account.globalRank) {
|
||||
user.socket.emit("errorMsg", {
|
||||
msg: "/smute failed - " + target.getName() + " has equal or higher rank " +
|
||||
msg: "!smute failed - " + target.getName() + " has equal or higher rank " +
|
||||
"than you."
|
||||
});
|
||||
return;
|
||||
|
|
@ -648,7 +719,7 @@ ChatModule.prototype.handleCmdUnmute = function (user, msg, _meta) {
|
|||
var name = args.shift();
|
||||
if (typeof name !== "string") {
|
||||
user.socket.emit("errorMsg", {
|
||||
msg: "/unmute requires a target name"
|
||||
msg: "!unmute requires a target name"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,60 +0,0 @@
|
|||
// TODO: figure out what to do with this module
|
||||
// it serves a very niche use case and is only a core module because of
|
||||
// legacy reasons (early channels requested it before I had criteria
|
||||
// around what to include in core)
|
||||
var ChannelModule = require("./module");
|
||||
|
||||
function DrinkModule(_channel) {
|
||||
ChannelModule.apply(this, arguments);
|
||||
this.drinks = 0;
|
||||
}
|
||||
|
||||
DrinkModule.prototype = Object.create(ChannelModule.prototype);
|
||||
|
||||
DrinkModule.prototype.onUserPostJoin = function (user) {
|
||||
user.socket.emit("drinkCount", this.drinks);
|
||||
};
|
||||
|
||||
DrinkModule.prototype.onUserPreChat = function (user, data, cb) {
|
||||
var msg = data.msg;
|
||||
var perms = this.channel.modules.permissions;
|
||||
if (msg.match(/^\/d-?[0-9]*/) && perms.canCallDrink(user)) {
|
||||
msg = msg.substring(2);
|
||||
var m = msg.match(/^(-?[0-9]+)/);
|
||||
var count;
|
||||
if (m) {
|
||||
count = parseInt(m[1]);
|
||||
if (isNaN(count) || count < -10000 || count > 10000) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg = msg.replace(m[1], "").trim();
|
||||
if (msg || count > 0) {
|
||||
msg += " drink! (x" + count + ")";
|
||||
} else {
|
||||
this.drinks += count;
|
||||
this.channel.broadcastAll("drinkCount", this.drinks);
|
||||
return cb(null, ChannelModule.DENY);
|
||||
}
|
||||
} else {
|
||||
msg = msg.trim() + " drink!";
|
||||
count = 1;
|
||||
}
|
||||
|
||||
this.drinks += count;
|
||||
this.channel.broadcastAll("drinkCount", this.drinks);
|
||||
data.msg = msg;
|
||||
data.meta.addClass = "drink";
|
||||
data.meta.forceShowName = true;
|
||||
cb(null, ChannelModule.PASSTHROUGH);
|
||||
} else {
|
||||
cb(null, ChannelModule.PASSTHROUGH);
|
||||
}
|
||||
};
|
||||
|
||||
DrinkModule.prototype.onMediaChange = function () {
|
||||
this.drinks = 0;
|
||||
this.channel.broadcastAll("drinkCount", 0);
|
||||
};
|
||||
|
||||
module.exports = DrinkModule;
|
||||
|
|
@ -1,3 +1,42 @@
|
|||
/*
|
||||
fore.st is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
fore.st is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with fore.st. If not, see < http://www.gnu.org/licenses/ >.
|
||||
(C) 2022- by rainbownapkin, <ourforest@420blaze.it>
|
||||
|
||||
Original cytube license:
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013-2022 Calvin Montgomery
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
var ChannelModule = require("./module");
|
||||
var db = require("../database");
|
||||
var Flags = require("../flags");
|
||||
|
|
@ -19,11 +58,10 @@ function KickBanModule(_channel) {
|
|||
ChannelModule.apply(this, arguments);
|
||||
|
||||
if (this.channel.modules.chat) {
|
||||
this.channel.modules.chat.registerCommand("/kick", this.handleCmdKick.bind(this));
|
||||
this.channel.modules.chat.registerCommand("/kickanons", this.handleCmdKickAnons.bind(this));
|
||||
this.channel.modules.chat.registerCommand("/ban", this.handleCmdBan.bind(this));
|
||||
this.channel.modules.chat.registerCommand("/ipban", this.handleCmdIPBan.bind(this));
|
||||
this.channel.modules.chat.registerCommand("/banip", this.handleCmdIPBan.bind(this));
|
||||
this.channel.modules.chat.registerCommand("!kick", this.handleCmdKick.bind(this));
|
||||
this.channel.modules.chat.registerCommand("!ban", this.handleCmdBan.bind(this));
|
||||
this.channel.modules.chat.registerCommand("!ipban", this.handleCmdIPBan.bind(this));
|
||||
this.channel.modules.chat.registerCommand("!banip", this.handleCmdIPBan.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -195,25 +233,6 @@ KickBanModule.prototype.handleCmdKick = function (user, msg, _meta) {
|
|||
}
|
||||
};
|
||||
|
||||
KickBanModule.prototype.handleCmdKickAnons = function (user, _msg, _meta) {
|
||||
if (!this.channel.modules.permissions.canKick(user)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var users = Array.prototype.slice.call(this.channel.users);
|
||||
users.forEach(function (u) {
|
||||
if (!u.is(Flags.U_LOGGED_IN)) {
|
||||
u.kick("anonymous user");
|
||||
}
|
||||
});
|
||||
|
||||
this.channel.logger.log("[mod] " + user.getName() + " kicked anonymous users.");
|
||||
if (this.channel.modules.chat) {
|
||||
this.channel.modules.chat.sendModMessage(user.getName() + " kicked anonymous " +
|
||||
"users");
|
||||
}
|
||||
};
|
||||
|
||||
/* /ban - name bans */
|
||||
KickBanModule.prototype.handleCmdBan = function (user, msg, _meta) {
|
||||
var args = msg.split(" ");
|
||||
|
|
|
|||
|
|
@ -1,3 +1,42 @@
|
|||
/*
|
||||
fore.st is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
fore.st is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with fore.st. If not, see < http://www.gnu.org/licenses/ >.
|
||||
(C) 2022- by rainbownapkin, <ourforest@420blaze.it>
|
||||
|
||||
Original cytube license:
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013-2022 Calvin Montgomery
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
var ChannelModule = require("./module"); var ULList = require("../ullist");
|
||||
var AsyncQueue = require("../asyncqueue");
|
||||
var Media = require("../media");
|
||||
|
|
@ -9,6 +48,7 @@ var db = require("../database");
|
|||
var CustomEmbedFilter = require("../customembed").filter;
|
||||
var XSS = require("../xss");
|
||||
import { Counter } from 'prom-client';
|
||||
import { validateTextTracks as tvalidate } from '../custom-media';
|
||||
|
||||
const LOGGER = require('@calzoneman/jsli')('playlist');
|
||||
|
||||
|
|
@ -27,7 +67,8 @@ const TYPE_QUEUE = {
|
|||
pos: "string",
|
||||
title: "string,boolean,optional",
|
||||
duration: "number,optional",
|
||||
temp: "boolean,optional"
|
||||
temp: "boolean,optional",
|
||||
subtitle: "string"
|
||||
};
|
||||
|
||||
const TYPE_SET_TEMP = {
|
||||
|
|
@ -105,8 +146,8 @@ function PlaylistModule(_channel) {
|
|||
this._refreshing = false;
|
||||
|
||||
if (this.channel.modules.chat) {
|
||||
this.channel.modules.chat.registerCommand("/clean", this.handleClean.bind(this));
|
||||
this.channel.modules.chat.registerCommand("/cleantitle", this.handleClean.bind(this));
|
||||
this.channel.modules.chat.registerCommand("!clean", this.handleClean.bind(this));
|
||||
this.channel.modules.chat.registerCommand("!cleantitle", this.handleClean.bind(this));
|
||||
}
|
||||
|
||||
this.supportsDirtyCheck = true;
|
||||
|
|
@ -407,7 +448,12 @@ PlaylistModule.prototype.handleQueue = function (user, data) {
|
|||
if (typeof data.title !== "string" || (data.type !== "cu" && data.type !== "fi")) {
|
||||
data.title = false;
|
||||
}
|
||||
|
||||
|
||||
if (!data.subtitle){
|
||||
data.subtitle = false;
|
||||
}
|
||||
|
||||
var link = util.formatLink(id, type, null);
|
||||
var perms = this.channel.modules.permissions;
|
||||
|
||||
|
|
@ -491,6 +537,7 @@ PlaylistModule.prototype.handleQueue = function (user, data) {
|
|||
type: data.type,
|
||||
pos: data.pos,
|
||||
title: data.title,
|
||||
subtitle: data.subtitle,
|
||||
link: link,
|
||||
temp: temp,
|
||||
shouldAddToLibrary: !temp,
|
||||
|
|
@ -1051,16 +1098,52 @@ PlaylistModule.prototype._addItem = function (media, data, user, cb) {
|
|||
media.setTitle(data.title);
|
||||
}
|
||||
|
||||
|
||||
console.log("pre media subload");
|
||||
console.log(data);
|
||||
if (data.subtitle && (media.type === "cu" || media.type === "fi")) {
|
||||
|
||||
|
||||
var ttracks = [{
|
||||
"url": data.subtitle,
|
||||
"contentType": "text/vtt",
|
||||
"name": "English Subs",
|
||||
"default": true
|
||||
}];
|
||||
|
||||
|
||||
console.log(Config.get('http.root-domain'));
|
||||
try {
|
||||
tvalidate(ttracks);
|
||||
} catch (error) {
|
||||
user.socket.emit("errorMsg", {
|
||||
msg: `Invalid text track error:` + error
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
media.meta.textTracks = ttracks;
|
||||
|
||||
}
|
||||
|
||||
var success = function () {
|
||||
var tempST = 0;
|
||||
//var packet = {
|
||||
// item: item.pack(),
|
||||
// after: item.prev ? item.prev.uid : "prepend"
|
||||
//};
|
||||
|
||||
|
||||
self.meta.count++;
|
||||
self.items.forEach(function (item){//iterate items
|
||||
self.items.find(item.uid).media.startTime = tempST;//current item start time = tempST
|
||||
tempST += item.media.seconds;
|
||||
});
|
||||
|
||||
|
||||
/*self.meta.count++;
|
||||
media.startTime = self.meta.rawTime;
|
||||
self.meta.rawTime += media.seconds;
|
||||
self.meta.time = util.formatTime(self.meta.rawTime);
|
||||
self.meta.time = util.formatTime(self.meta.rawTime);*/ //old buggy shit
|
||||
|
||||
var sTemp = [[],[]];
|
||||
|
||||
|
|
@ -1297,8 +1380,8 @@ PlaylistModule.prototype.handleClean = function (user, msg, _meta) {
|
|||
var cmd = args.shift();
|
||||
if (args.length === 0) {
|
||||
return user.socket.emit("errorMsg", {
|
||||
msg: "No target given for " + cmd + ". Usage: /clean <username> or " +
|
||||
"/cleantitle <title>"
|
||||
msg: "No target given for " + cmd + ". Usage: !clean <username> or " +
|
||||
"!cleantitle <title>"
|
||||
});
|
||||
}
|
||||
var target;
|
||||
|
|
@ -1315,9 +1398,9 @@ PlaylistModule.prototype.handleClean = function (user, msg, _meta) {
|
|||
" with target regex: " + target);
|
||||
|
||||
var cleanfn;
|
||||
if (cmd === "/clean") {
|
||||
if (cmd === "!clean") {
|
||||
cleanfn = function (item) { return target.test(item.queueby); };
|
||||
} else if (cmd === "/cleantitle") {
|
||||
} else if (cmd === "!cleantitle") {
|
||||
cleanfn = function (item) { return target.exec(item.media.title) !== null; };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ function PollModule(_channel) {
|
|||
this.roomViewHidden = this.channel.uniqueName + ROOM_VIEW_HIDDEN;
|
||||
this.roomNoViewHidden = this.channel.uniqueName + ROOM_NO_VIEW_HIDDEN;
|
||||
if (this.channel.modules.chat) {
|
||||
this.channel.modules.chat.registerCommand("poll", this.handlePollCmd.bind(this, false));
|
||||
this.channel.modules.chat.registerCommand("hpoll", this.handlePollCmd.bind(this, true));
|
||||
this.channel.modules.chat.registerCommand("!poll", this.handlePollCmd.bind(this, false));
|
||||
this.channel.modules.chat.registerCommand("!hpoll", this.handlePollCmd.bind(this, true));
|
||||
}
|
||||
this.supportsDirtyCheck = true;
|
||||
}
|
||||
|
|
@ -254,7 +254,8 @@ PollModule.prototype.handlePollCmd = function (obscured, user, msg, _meta) {
|
|||
// Ensure any existing poll is closed
|
||||
this.handleClosePoll(user);
|
||||
|
||||
msg = msg.replace(/^\/h?poll/, "");
|
||||
msg = msg.replace(/^!h?poll/, "");
|
||||
//msg = msg.replace(/^\/h?poll/, "");
|
||||
|
||||
var args = msg.split(",");
|
||||
var title = args.shift();
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ function validateSources(sources, data) {
|
|||
}
|
||||
}
|
||||
|
||||
function validateTextTracks(textTracks) {
|
||||
export function validateTextTracks(textTracks) {
|
||||
if (typeof textTracks === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
13
src/user.js
13
src/user.js
|
|
@ -102,10 +102,15 @@ User.prototype.handleJoinChannel = function handleJoinChannel(data) {
|
|||
|
||||
if (!chan.is(Flags.C_READY)) {
|
||||
chan.once("loadFail", reason => {
|
||||
this.socket.emit("errorMsg", {
|
||||
msg: reason,
|
||||
alert: true
|
||||
});
|
||||
|
||||
if(reason == "Channel not found."){
|
||||
this.socket.emit("channelNotFound");
|
||||
}else{
|
||||
this.socket.emit("errorMsg", {
|
||||
msg: reason,
|
||||
alert: true
|
||||
});
|
||||
}
|
||||
this.kick(`Channel could not be loaded: ${reason}`);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue