, nickname
, primus
, pvtmsgto
+ , replyto
, roomname = location.pathname.replace(/\//g, '')
, roundpoints = 0
, subscriber = false
, timer
, urlregex = /(https?:\/\/[\-A-Za-z0-9+&@#\/%?=~_()|!:,.;]*[\-A-Za-z0-9+&@#\/%=~_()|])/
- , userscounters = {};
+ , userscounters = {}
+ , usersnicks = [];
var amstrings = [
'Do you also know the title?'
if (to) {
// Private Message
- prefix = '(' + (nickname === from ? 'To ' + to : 'From ' + prefix) + ')';
+ if (nickname === from ) {
+ prefix = '(To ' + to + ')';
+ }
+ else {
+ prefix = '(From ' + from + ')';
+ replyto = from;
+ }
$message.addClass('private');
}
$messagebox.val('');
if (value) {
- if (pvtmsgto) {
- return primus.send('chatmsg', value, pvtmsgto);
- }
-
if (/^\/[^ ]/.test(value)) {
return slashCommandHandler(value);
}
+ if (pvtmsgto) {
+ return primus.send('chatmsg', value, pvtmsgto);
+ }
+
primus.send('chatmsg', value);
}
}
addChatEntry($outcome);
};
+ // Send a private message to a user
+ var privateMessage = function(args, $outcome) {
+ if ($.inArray(args[0], usersnicks) === -1) {
+ $outcome.text('(From binb): There\'s noone here by that name.');
+ return addChatEntry($outcome);
+ }
+ return addPrivate(args[0]);
+ };
+
+ // Reply to the last player who sent you a private message
+ var replyToPrivate = function(args, $outcome) {
+ if (!replyto) {
+ $outcome.text('(From binb): There\'s noone to reply to.');
+ return addChatEntry($outcome);
+ }
+ if ($.inArray(replyto, usersnicks) === -1) {
+ $outcome.text('(From binb):' + replyto + ' isn\'t here anymore.');
+ return addChatEntry($outcome);
+ }
+ return addPrivate(replyto);
+ };
+
// Unban a player
var unbanPlayer = function(args, $outcome) {
$outcome.append('you are not allowed to unban a player.');
// Flag to test if our private recipient is in the list of active users
var found = false;
+ usersnicks = [];
+
users.forEach(function(user, index) {
var $guesstime = $('<span class="guess-time"></span>')
, $li = $('<li></li>')
$roundrank.addClass('icons round-rank stand' + (7 - user.roundpoints));
}
}
+ usersnicks.push(user.nickname);
});
if (!found && pvtmsgto) {
fn: unignorePlayer,
minargs: 1,
usage: 'usage: /unignore <player>'
+ },
+ private: {
+ checkrecipient: true,
+ fn: privateMessage,
+ minargs: 1,
+ usage: 'usage: /private <player>',
+ },
+ reply: {
+ fn: replyToPrivate,
+ minargs: 0,
+ },
+ unprivate: {
+ fn: clearPrivate,
+ minargs: 0,
}
};