From cccfd514d1ebb673f62f0b437529f753f9002ae5 Mon Sep 17 00:00:00 2001 From: Slayer95 Date: Tue, 20 Aug 2013 20:13:40 -0500 Subject: [PATCH] Improve canBroadcast() If still in cooldown, the command is not added to the room anymore, and a message is sent to the user. If an unauthorized user attempts to broadcast, the error message is now sent to the current room rather than to Lobby. --- command-parser.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/command-parser.js b/command-parser.js index c9930e3d5c..b2f7d1b466 100644 --- a/command-parser.js +++ b/command-parser.js @@ -153,19 +153,19 @@ var parse = exports.parse = function(message, room, user, connection, levelsDeep message = this.canTalk(message); if (!message) return false; if (!user.can('broadcast', null, room)) { - connection.send("You need to be voiced to broadcast this command's information."); - connection.send("To see it for yourself, use: /"+message.substr(1)); + connection.sendTo(room, "You need to be voiced to broadcast this command's information."); + connection.send(room, "To see it for yourself, use: /"+message.substr(1)); return false; } - this.add('|c|'+user.getIdentity(room.id)+'|'+message); - // broadcast cooldown var normalized = toId(message); if (room.lastBroadcast === normalized && room.lastBroadcastTime >= Date.now() - BROADCAST_COOLDOWN) { + connection.sendTo(room, "You can't broadcast this because it was just broadcast.") return false; } + this.add('|c|'+user.getIdentity(room.id)+'|'+message); room.lastBroadcast = normalized; room.lastBroadcastTime = Date.now();