Skip to content

Commit

Permalink
Use either command character for clientside commands (smogon#1134)
Browse files Browse the repository at this point in the history
  • Loading branch information
iscke authored and Zarel committed Aug 6, 2018
1 parent 4f2d776 commit f4ea4f3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion js/client-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@
var cmd = '';
var target = '';
var noSpace = false;
if (text.substr(0, 2) !== '//' && text.charAt(0) === '/') {
if (text.substr(0, 2) !== '//' && text.charAt(0) === '/' || text.charAt(0) === '!') {
var spaceIndex = text.indexOf(' ');
if (spaceIndex > 0) {
cmd = text.substr(1, spaceIndex - 1);
Expand Down
37 changes: 27 additions & 10 deletions js/client-mainmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,32 +314,49 @@
var $chat = $pmWindow.find('.inner');
// this.tabComplete.reset();
this.chatHistories[userid].push(text);

var data = '';
var cmd = text.toLowerCase();
var spaceIndex = cmd.indexOf(' ');
if (spaceIndex > 0) {
data = cmd.substr(spaceIndex + 1);
cmd = cmd.substr(0, spaceIndex);
var cmd = '';
var spaceIndex = text.indexOf(' ');
if (text.substr(0, 2) !== '//' && text.charAt(0) === '/' || text.charAt(0) === '!') {
if (spaceIndex > 0) {
data = text.substr(spaceIndex);
cmd = text.substr(1, spaceIndex - 1);
} else {
data = '';
cmd = text.substr(1);
}
}
if (cmd === '/ignore') {
switch (cmd.toLowerCase()) {
case 'ignore':
if (app.ignore[userid]) {
$chat.append('<div class="chat">User ' + userid + ' is already on your ignore list. (Moderator messages will not be ignored.)</div>');
} else {
app.ignore[userid] = 1;
$chat.append('<div class="chat">User ' + userid + ' ignored. (Moderator messages will not be ignored.)</div>');
}
} else if (cmd === '/unignore') {
break;
case 'unignore':
if (!app.ignore[userid]) {
$chat.append('<div class="chat">User ' + userid + ' isn\'t on your ignore list.</div>');
} else {
delete app.ignore[userid];
$chat.append('<div class="chat">User ' + userid + ' no longer ignored.</div>');
}
} else if (cmd === '/challenge') {
break;
case 'challenge':
this.challenge(userid, data);
} else if (cmd === '/clear') {
break;
case 'clear':
$chat.empty();
} else {
break;
case 'rank':
case 'ranking':
case 'rating':
case 'ladder':
$chat.append('<div class="chat">Use this command in a proper chat room.</div>');
break;
default:
text = ('\n' + text).replace(/\n\n/g, '\n').replace(/\n/g, '\n/pm ' + userid + ', ').substr(1);
if (text.length > 80000) {
app.addPopupMessage("Your message is too long.");
Expand Down

0 comments on commit f4ea4f3

Please sign in to comment.