Allow chaining for /m

This commit is contained in:
calzoneman 2013-04-28 13:04:15 -05:00
parent 8d6b228f8f
commit 406988aef1
5 changed files with 20 additions and 18 deletions

View File

@ -1145,14 +1145,18 @@ Channel.prototype.tryChat = function(user, data) {
return;
}
this.chainMessage(user, msg);
}
Channel.prototype.chainMessage = function(user, msg, data) {
if(msg.indexOf("/") == 0)
ChatCommand.handle(this, user, msg);
ChatCommand.handle(this, user, msg, data);
else if(msg.indexOf(">") == 0)
this.sendMessage(user.name, msg, "greentext");
this.sendMessage(user.name, msg, "greentext", data);
else
this.sendMessage(user.name, msg, "");
this.sendMessage(user.name, msg, "", data);
}
Channel.prototype.filterMessage = function(msg) {

View File

@ -13,14 +13,14 @@ var Rank = require("./rank.js");
var Poll = require("./poll.js").Poll;
var Logger = require("./logger.js");
function handle(chan, user, msg) {
function handle(chan, user, msg, data) {
if(msg.indexOf("/me ") == 0)
chan.sendMessage(user.name, msg.substring(4), "action");
chan.sendMessage(user.name, msg.substring(4), "action", data);
else if(msg.indexOf("/sp ") == 0)
chan.sendMessage(user.name, msg.substring(4), "spoiler");
chan.sendMessage(user.name, msg.substring(4), "spoiler", data);
else if(msg.indexOf("/say ") == 0) {
if(Rank.hasPermission(user, "shout") || chan.leader == user) {
chan.sendMessage(user.name, msg.substring(5), "shout");
chan.sendMessage(user.name, msg.substring(5), "shout", data);
}
}
else if(msg.indexOf("/afk") == 0) {
@ -29,9 +29,7 @@ function handle(chan, user, msg) {
}
else if(msg.indexOf("/m ") == 0) {
if(user.rank >= Rank.Moderator) {
chan.sendMessage(user.name, msg.substring(3), "modflair", {
modflair: user.rank
});
chan.chainMessage(user, msg.substring(3), {modflair: user.rank})
}
}
else if(msg.indexOf("/kick ") == 0) {
@ -48,7 +46,7 @@ function handle(chan, user, msg) {
}
else if(msg.indexOf("/d") == 0 && msg.length > 2 &&
msg[2].match(/[-0-9 ]/)) {
handleDrink(chan, user, msg.substring(2));
handleDrink(chan, user, msg.substring(2), data);
}
}
@ -108,7 +106,7 @@ function handlePoll(chan, user, msg) {
}
}
function handleDrink(chan, user, msg) {
function handleDrink(chan, user, msg, data) {
if(!Rank.hasPermission(user, "drink") && chan.leader != user) {
return;
}
@ -129,7 +127,7 @@ function handleDrink(chan, user, msg) {
msg = msg + " drink!";
if(count != 1)
msg += " (x" + count + ")";
chan.sendMessage(user.name, msg, "drink");
chan.sendMessage(user.name, msg, "drink", data);
}
exports.handle = handle;

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery",
"name": "CyTube",
"description": "Online media synchronizer and chat",
"version": "1.4.0",
"version": "1.4.1",
"repository": {
"url": "http://github.com/calzoneman/sync"
},

View File

@ -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.4.0";
const VERSION = "1.4.1";
var fs = require("fs");
var Logger = require("./logger.js");

View File

@ -207,6 +207,9 @@ function formatChatMessage(data) {
$("<strong/>").text("<" + data.username + "> ").appendTo(name);
var message = $("<span/>").appendTo(div);
message[0].innerHTML = data.msg;
if(data.modflair) {
name.addClass(getNameColor(data.modflair));
}
if(data.msgclass == "action") {
name.remove();
message.addClass("action");
@ -219,9 +222,6 @@ function formatChatMessage(data) {
message.addClass("shout");
name.addClass("shout");
}
else if(data.modflair) {
name.addClass(getNameColor(data.modflair));
}
else {
message.addClass(data.msgclass);
}