Add basic shadow mute command
This commit is contained in:
parent
e737bc9f8a
commit
6588e90bfe
|
|
@ -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
|
Fri Nov 08 17:55 2013 CDT
|
||||||
* lib/get-info.js: Strip "ip" and "expire" fields from Google Drive
|
* lib/get-info.js: Strip "ip" and "expire" fields from Google Drive
|
||||||
flashvars
|
flashvars
|
||||||
|
|
|
||||||
|
|
@ -2201,6 +2201,19 @@ Channel.prototype.tryChat = function(user, data) {
|
||||||
return;
|
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);
|
this.chainMessage(user, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,9 @@ function handle(chan, user, msg, data) {
|
||||||
else if(msg.indexOf("/mute ") == 0) {
|
else if(msg.indexOf("/mute ") == 0) {
|
||||||
handleMute(chan, user, msg.substring(6).split(" "));
|
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) {
|
else if(msg.indexOf("/unmute ") == 0) {
|
||||||
handleUnmute(chan, user, msg.substring(8).split(" "));
|
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) {
|
function handleMute(chan, user, args) {
|
||||||
if(chan.hasPermission(user, "mute") && args.length > 0) {
|
if(chan.hasPermission(user, "mute") && args.length > 0) {
|
||||||
args[0] = args[0].toLowerCase();
|
args[0] = args[0].toLowerCase();
|
||||||
|
|
@ -144,6 +182,7 @@ function handleUnmute(chan, user, args) {
|
||||||
}
|
}
|
||||||
person.meta.icon = false;
|
person.meta.icon = false;
|
||||||
chan.mutedUsers.remove(person.name.toLowerCase());
|
chan.mutedUsers.remove(person.name.toLowerCase());
|
||||||
|
chan.mutedUsers.remove("[shadow]" + person.name.toLowerCase());
|
||||||
chan.broadcastUserUpdate(person);
|
chan.broadcastUserUpdate(person);
|
||||||
chan.logger.log("*** " + user.name + " unmuted " + args[0]);
|
chan.logger.log("*** " + user.name + " unmuted " + args[0]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue