Add basic shadow mute command

This commit is contained in:
calzoneman 2013-11-08 20:45:59 -06:00
parent e737bc9f8a
commit 6588e90bfe
3 changed files with 56 additions and 0 deletions

View File

@ -1,3 +1,7 @@
Fri Nov 08 20:44 2013 CDT
* lib/channel.js, lib/chatcommand.js: Implement basic shadow mute
command
Fri Nov 08 17:55 2013 CDT
* lib/get-info.js: Strip "ip" and "expire" fields from Google Drive
flashvars

View File

@ -2201,6 +2201,19 @@ Channel.prototype.tryChat = function(user, data) {
return;
}
if (this.mutedUsers.contains("[shadow]" + user.name.toLowerCase())) {
msg = sanitize(msg).escape();
msg = this.filterMessage(msg);
var msgobj = {
username: user.name,
msg: msg,
msgclass: "",
time: Date.now()
};
user.socket.emit("chatMsg", msgobj);
return;
}
this.chainMessage(user, msg);
}

View File

@ -56,6 +56,9 @@ function handle(chan, user, msg, data) {
else if(msg.indexOf("/mute ") == 0) {
handleMute(chan, user, msg.substring(6).split(" "));
}
else if(msg.indexOf("/smute ") == 0) {
handleShadowMute(chan, user, msg.substring(7).split(" "));
}
else if(msg.indexOf("/unmute ") == 0) {
handleUnmute(chan, user, msg.substring(8).split(" "));
}
@ -98,6 +101,41 @@ function handle(chan, user, msg, data) {
}
}
function handleShadowMute(chan, user, args) {
if(chan.hasPermission(user, "mute") && args.length > 0) {
args[0] = args[0].toLowerCase();
var person = false;
for(var i = 0; i < chan.users.length; i++) {
if(chan.users[i].name.toLowerCase() == args[0]) {
person = chan.users[i];
break;
}
}
if(person) {
if(person.rank >= user.rank) {
user.socket.emit("errorMsg", {
msg: "You don't have permission to mute that person."
});
return;
}
chan.mutedUsers.add("[shadow]" + person.name.toLowerCase());
chan.logger.log("*** " + user.name + " shadow muted " + args[0]);
var pkt = {
username: "[server]",
msg: user.name + " shadow muted " + args[0],
msgclass: "server-whisper",
time: Date.now()
};
chan.users.forEach(function (u) {
if (u.rank >= 2) {
u.socket.emit("chatMsg", pkt);
}
});
}
}
}
function handleMute(chan, user, args) {
if(chan.hasPermission(user, "mute") && args.length > 0) {
args[0] = args[0].toLowerCase();
@ -144,6 +182,7 @@ function handleUnmute(chan, user, args) {
}
person.meta.icon = false;
chan.mutedUsers.remove(person.name.toLowerCase());
chan.mutedUsers.remove("[shadow]" + person.name.toLowerCase());
chan.broadcastUserUpdate(person);
chan.logger.log("*** " + user.name + " unmuted " + args[0]);
}