mirror of https://github.com/calzoneman/sync.git
Add /say and global announcements
This commit is contained in:
parent
755c4f49fd
commit
c50dbece97
|
@ -6,6 +6,11 @@ function handle(chan, user, msg) {
|
||||||
chan.sendMessage(user.name, msg.substring(4), "action");
|
chan.sendMessage(user.name, msg.substring(4), "action");
|
||||||
else if(msg.indexOf("/sp ") == 0)
|
else if(msg.indexOf("/sp ") == 0)
|
||||||
chan.sendMessage(user.name, msg.substring(4), "spoiler");
|
chan.sendMessage(user.name, msg.substring(4), "spoiler");
|
||||||
|
else if(msg.indexOf("/say ") == 0) {
|
||||||
|
if(Rank.hasPermission(user, "shout")) {
|
||||||
|
chan.sendMessage(user.name, msg.substring(5), "shout");
|
||||||
|
}
|
||||||
|
}
|
||||||
else if(msg.indexOf("/kick ") == 0) {
|
else if(msg.indexOf("/kick ") == 0) {
|
||||||
handleKick(chan, user, msg.substring(6).split(' '));
|
handleKick(chan, user, msg.substring(6).split(' '));
|
||||||
}
|
}
|
||||||
|
|
22
rank.js
22
rank.js
|
@ -13,16 +13,18 @@ exports.Owner = 3;
|
||||||
exports.Siteadmin = 255;
|
exports.Siteadmin = 255;
|
||||||
|
|
||||||
var permissions = {
|
var permissions = {
|
||||||
acp: exports.Siteadmin,
|
acp : exports.Siteadmin,
|
||||||
registerChannel: exports.Owner,
|
announce : exports.Siteadmin,
|
||||||
queue: exports.Moderator,
|
registerChannel : exports.Owner,
|
||||||
assignLeader: exports.Moderator,
|
queue : exports.Moderator,
|
||||||
kick: exports.Moderator,
|
assignLeader : exports.Moderator,
|
||||||
promote: exports.Moderator,
|
kick : exports.Moderator,
|
||||||
qlock: exports.Moderator,
|
promote : exports.Moderator,
|
||||||
poll: exports.Moderator,
|
qlock : exports.Moderator,
|
||||||
search: exports.Guest,
|
poll : exports.Moderator,
|
||||||
chat: exports.Guest,
|
shout : exports.Moderator,
|
||||||
|
search : exports.Guest,
|
||||||
|
chat : exports.Guest,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check if someone has permission to do shit
|
// Check if someone has permission to do shit
|
||||||
|
|
15
user.js
15
user.js
|
@ -23,6 +23,9 @@ var User = function(socket, ip) {
|
||||||
this.name = "";
|
this.name = "";
|
||||||
|
|
||||||
this.initCallbacks();
|
this.initCallbacks();
|
||||||
|
if(Server.announcement != null) {
|
||||||
|
this.socket.emit('announcement', Server.announcement);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set up socket callbacks
|
// Set up socket callbacks
|
||||||
|
@ -182,6 +185,18 @@ User.prototype.initCallbacks = function() {
|
||||||
this.handleAdm(data);
|
this.handleAdm(data);
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
this.socket.on('announce', function(data) {
|
||||||
|
if(Rank.hasPermission(this, "announce")) {
|
||||||
|
if(data.clear) {
|
||||||
|
Server.announcement = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Server.io.sockets.emit('announcement', data);
|
||||||
|
Server.announcement = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle administration
|
// Handle administration
|
||||||
|
|
|
@ -56,6 +56,14 @@
|
||||||
border-left: 0;
|
border-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#messagebuffer div {
|
||||||
|
white-space: pre-wrap; /* css-3 */
|
||||||
|
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
|
||||||
|
white-space: -pre-wrap; /* Opera 4-6 */
|
||||||
|
white-space: -o-pre-wrap; /* Opera 7 */
|
||||||
|
word-wrap: break-word; /* Internet Explorer 5.5+ */
|
||||||
|
}
|
||||||
|
|
||||||
#chatline {
|
#chatline {
|
||||||
width: 456px;
|
width: 456px;
|
||||||
}
|
}
|
||||||
|
@ -71,12 +79,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.userlist_op {
|
.userlist_op {
|
||||||
color: #00cc00;
|
color: #00aa00;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action {
|
.action {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
color: #aaaaaa;
|
color: #888888;
|
||||||
}
|
}
|
||||||
|
|
||||||
.spoiler {
|
.spoiler {
|
||||||
|
@ -92,6 +100,12 @@
|
||||||
color: #789922; /* Color value directly from 4chan */
|
color: #789922; /* Color value directly from 4chan */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.shout {
|
||||||
|
color: #ff0000;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 18pt;
|
||||||
|
}
|
||||||
|
|
||||||
.option button {
|
.option button {
|
||||||
margin-right: 15px;
|
margin-right: 15px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,10 @@ function initCallbacks() {
|
||||||
showChannelRegistration();
|
showChannelRegistration();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('announcement', function(data) {
|
||||||
|
showAnnouncement(data.title, data.text);
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('registerChannel', function(data) {
|
socket.on('registerChannel', function(data) {
|
||||||
if(data.success) {
|
if(data.success) {
|
||||||
$('#chregnotice').remove();
|
$('#chregnotice').remove();
|
||||||
|
|
|
@ -128,6 +128,8 @@ function formatChatMessage(data) {
|
||||||
var name = document.createElement('span');
|
var name = document.createElement('span');
|
||||||
var message = document.createElement('span');
|
var message = document.createElement('span');
|
||||||
name.innerHTML = "<strong><" + data.username + "></strong> ";
|
name.innerHTML = "<strong><" + data.username + "></strong> ";
|
||||||
|
if(data.msgclass == "shout")
|
||||||
|
$(name).addClass("shout");
|
||||||
$(message).addClass(data.msgclass);
|
$(message).addClass(data.msgclass);
|
||||||
message.innerHTML = data.msg;
|
message.innerHTML = data.msg;
|
||||||
div.appendChild(name);
|
div.appendChild(name);
|
||||||
|
@ -517,3 +519,13 @@ function showChannelRegistration() {
|
||||||
socket.emit('registerChannel');
|
socket.emit('registerChannel');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showAnnouncement(title, text) {
|
||||||
|
var div = $('<div/>').addClass('alert')
|
||||||
|
.insertAfter($('.row')[0]);
|
||||||
|
$('<button/>').addClass('close pull-right').text('×')
|
||||||
|
.appendTo(div)
|
||||||
|
.click(function() { div.remove(); });
|
||||||
|
$('<h3/>').text(title).appendTo(div);
|
||||||
|
$('<p/>').html(text).appendTo(div);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue