Fixes and stuff
This commit is contained in:
parent
362fd0ab23
commit
0e49f06fbf
19
channel.js
19
channel.js
|
@ -18,6 +18,7 @@ var Logger = require("./logger.js");
|
|||
var InfoGetter = require("./get-info.js");
|
||||
var io = require("./server.js").io;
|
||||
var Rank = require("./rank.js");
|
||||
var ChatCommand = require("./chatcommand.js");
|
||||
|
||||
var Channel = function(name) {
|
||||
Logger.syslog.log("Opening channel " + name);
|
||||
|
@ -30,6 +31,7 @@ var Channel = function(name) {
|
|||
this.library = {};
|
||||
this.position = -1;
|
||||
this.media = null;
|
||||
this.drinks = 0;
|
||||
this.leader = null;
|
||||
this.chatbuffer = [];
|
||||
this.openqueue = false;
|
||||
|
@ -297,6 +299,7 @@ Channel.prototype.userJoin = function(user) {
|
|||
}
|
||||
user.socket.emit("channelOpts", this.opts);
|
||||
user.socket.emit("updateMotd", this.motd);
|
||||
user.socket.emit("drinkCount", {count: this.drinks});
|
||||
|
||||
// Send things that require special permission
|
||||
this.sendRankStuff(user);
|
||||
|
@ -479,6 +482,10 @@ Channel.prototype.broadcastMotd = function() {
|
|||
this.sendAll("updateMotd", this.motd);
|
||||
}
|
||||
|
||||
Channel.prototype.broadcastDrinks = function() {
|
||||
this.sendAll("drinkCount", {count: this.drinks});
|
||||
}
|
||||
|
||||
/* REGION Playlist Stuff */
|
||||
|
||||
// The server autolead function
|
||||
|
@ -709,12 +716,16 @@ Channel.prototype.tryUpdate = function(user, data) {
|
|||
return;
|
||||
}
|
||||
|
||||
if(data.id == undefined || data.currentTime == undefined) {
|
||||
if(data == null ||
|
||||
data.id == undefined || data.currentTime == undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.media != null && (this.media.type == "li" ||
|
||||
this.media.type == "tw")) {
|
||||
if(this.media == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.media.type == "li" || this.media.type == "tw") {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -956,7 +967,7 @@ Channel.prototype.sendMessage = function(username, msg, msgclass) {
|
|||
msg: msg,
|
||||
msgclass: msgclass
|
||||
});
|
||||
this.recentChat.push({
|
||||
this.chatbuffer.push({
|
||||
username: username,
|
||||
msg: msg,
|
||||
msgclass: msgclass
|
||||
|
|
|
@ -35,6 +35,10 @@ function handle(chan, user, msg) {
|
|||
else if(msg.indexOf("/poll ") == 0) {
|
||||
handlePoll(chan, user, msg.substring(6));
|
||||
}
|
||||
else if(msg.indexOf("/d") == 0 && msg.length > 2 &&
|
||||
msg[2].match(/[-0-9 ]/)) {
|
||||
handleDrink(chan, user, msg.substring(2));
|
||||
}
|
||||
}
|
||||
|
||||
function handleKick(chan, user, args) {
|
||||
|
@ -88,5 +92,29 @@ function handlePoll(chan, user, msg) {
|
|||
}
|
||||
}
|
||||
|
||||
function handleDrink(chan, user, msg) {
|
||||
if(!Rank.hasPermission(user, "drink") && chan.leader != user) {
|
||||
return;
|
||||
}
|
||||
|
||||
var count = msg.split(" ")[0];
|
||||
msg = msg.substring(count.length + 1);
|
||||
if(count == "")
|
||||
count = 1;
|
||||
else
|
||||
count = parseInt(count);
|
||||
|
||||
chan.drinks += count;
|
||||
chan.broadcastDrinks();
|
||||
if(count < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg = msg + " drink!";
|
||||
if(count > 1)
|
||||
msg += " (x" + count + ")";
|
||||
chan.sendMessage(user.name, msg, "drink");
|
||||
}
|
||||
|
||||
exports.handle = handle;
|
||||
|
||||
|
|
1
rank.js
1
rank.js
|
@ -31,6 +31,7 @@ var permissions = {
|
|||
jump : exports.Moderator,
|
||||
chatFilter : exports.Moderator,
|
||||
updateMotd : exports.Moderator,
|
||||
drink : exports.Moderator,
|
||||
search : exports.Guest,
|
||||
chat : exports.Guest,
|
||||
};
|
||||
|
|
|
@ -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.1.0";
|
||||
const VERSION = "1.1.1";
|
||||
|
||||
var fs = require("fs");
|
||||
var Logger = require("./logger.js");
|
||||
|
|
|
@ -125,6 +125,18 @@
|
|||
background-color: #ddffdd;
|
||||
}
|
||||
|
||||
.drink {
|
||||
margin: 10px 10px;
|
||||
padding: 10px 0px;
|
||||
border: 2px solid #0000cc;
|
||||
}
|
||||
|
||||
.drinkbar {
|
||||
background-color: #000000;
|
||||
color: #ffffff;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#motdtext {
|
||||
width: 100%;
|
||||
}
|
||||
|
|
|
@ -189,6 +189,17 @@ function initCallbacks() {
|
|||
}
|
||||
});
|
||||
|
||||
socket.on("drinkCount", function(data) {
|
||||
var count = data.count;
|
||||
if(count != 0) {
|
||||
$("#drinkcount").text(count + " drinks");
|
||||
$(".drinkbar").show();
|
||||
}
|
||||
else {
|
||||
$(".drinkbar").hide();
|
||||
}
|
||||
});
|
||||
|
||||
/* REGION Playlist Stuff */
|
||||
|
||||
socket.on("playlist", function(data) {
|
||||
|
|
|
@ -140,6 +140,14 @@ function formatChatMessage(data) {
|
|||
.addClass("action")
|
||||
.appendTo(div);
|
||||
}
|
||||
else if(data.msgclass == "drink") {
|
||||
div.addClass("drink");
|
||||
var name = $("<span/>");
|
||||
$("<strong/>").text("<" + data.username + ">").appendTo(name);
|
||||
var message = $("<span/>").text(data.msg);
|
||||
name.appendTo(div);
|
||||
message.appendTo(div);
|
||||
}
|
||||
else {
|
||||
var name = $("<span/>");
|
||||
$("<strong/>").text("<" + data.username + ">").appendTo(name);
|
||||
|
|
|
@ -52,6 +52,9 @@
|
|||
<div class="span10 offset1 well">
|
||||
<p id="motd"></p>
|
||||
</div>
|
||||
<div class="span12 drinkbar">
|
||||
<h1 id="drinkcount"></h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="margin-top: 20px;">
|
||||
<div class="span5" id="chatdiv">
|
||||
|
|
Loading…
Reference in a new issue