Fixes; implement /clear command

This commit is contained in:
calzoneman 2013-05-23 00:03:37 -04:00
parent 4e364f45a6
commit a5c297365c
6 changed files with 23 additions and 15 deletions

View File

@ -115,10 +115,9 @@ Channel.prototype.hasPermission = function(user, key) {
if(key.indexOf("playlist") == 0 && this.openqueue) {
var key2 = "o" + key;
var v = this.permissions[key2];
if(typeof v != "number") {
return false;
if(typeof v == "number" && user.rank >= v) {
return true;
}
return user.rank >= v;
}
var v = this.permissions[key];
if(typeof v != "number") {
@ -1723,6 +1722,7 @@ Channel.prototype.changeLeader = function(name) {
if(name == "") {
this.logger.log("*** Resuming autolead");
if(this.media != null && !isLive(this.media.type)) {
this.media.paused = false;
this.time = new Date().getTime();
this.i = 0;
mediaUpdate(this, this.media.id);

View File

@ -51,6 +51,9 @@ function handle(chan, user, msg, data) {
msg[2].match(/[-0-9 ]/)) {
handleDrink(chan, user, msg.substring(2), data);
}
else if(msg.indexOf("/clear") == 0) {
handleClear(chan, user);
}
}
function handleKick(chan, user, args) {
@ -147,5 +150,14 @@ function handleDrink(chan, user, msg, data) {
chan.sendMessage(user.name, msg, "drink", data);
}
function handleClear(chan, user) {
if(user.rank < Rank.Moderator) {
return;
}
chan.chatbuffer = [];
chan.sendAll("clearchat");
}
exports.handle = handle;

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery",
"name": "CyTube",
"description": "Online media synchronizer and chat",
"version": "1.8.2",
"version": "1.9.0",
"repository": {
"url": "http://github.com/calzoneman/sync"
},

View File

@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c
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.
*/
const VERSION = "1.8.2";
const VERSION = "1.9.0";
var fs = require("fs");
var Logger = require("./logger.js");

View File

@ -186,13 +186,6 @@ Callbacks = {
},
channelOpts: function(opts) {
$("#opt_qopen_allow_anon").prop("checked", opts.qopen_allow_anon);
$("#opt_qopen_allow_guest").prop("checked", opts.qopen_allow_guest);
$("#opt_qopen_allow_qnext").prop("checked", opts.qopen_allow_qnext);
$("#opt_qopen_allow_move").prop("checked", opts.qopen_allow_move);
$("#opt_qopen_allow_delete").prop("checked", opts.qopen_allow_delete);
$("#opt_qopen_allow_playnext").prop("checked", opts.qopen_allow_playnext);
$("#opt_qopen_temp").prop("checked", opts.qopen_temp);
$("#opt_pagetitle").attr("placeholder", opts.pagetitle);
document.title = opts.pagetitle;
PAGETITLE = opts.pagetitle;
@ -473,6 +466,10 @@ Callbacks = {
addChatMessage(data);
},
clearchat: function() {
$("#messagebuffer").html("");
},
userlist: function(data) {
$(".userlist_item").each(function() { $(this).remove(); });
for(var i = 0; i < data.length; i++) {

View File

@ -1154,10 +1154,9 @@ function hasPermission(key) {
if(key.indexOf("playlist") == 0 && OPENQUEUE) {
var key2 = "o" + key;
var v = CHANPERMS[key2];
if(typeof v != "number") {
return false;
if(typeof v == "number" && RANK >= v) {
return true;
}
return RANK >= v;
}
var v = CHANPERMS[key];
if(typeof v != "number") {