Skip to content

Commit d6f5404

Browse files
committed
Rename CommandParser to Chat
We had a lot of discussion in Dev and a somewhat-close poll, but in the end "Chat" was a better name than "Messages", and also has the advantage of being shorter (which is nice for Chat.html and Chat.plural which should be short).
1 parent 56792d6 commit d6f5404

27 files changed

+196
-195
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"globals": {
1515
"Config": false, "Monitor": false, "toId": false, "Tools": false, "LoginServer": false,
16-
"Users": false, "Punishments": false, "Rooms": false, "Verifier": false, "CommandParser": false, "Simulator": false,
16+
"Users": false, "Punishments": false, "Rooms": false, "Verifier": false, "Chat": false, "Simulator": false,
1717
"Tournaments": false, "Dnsbl": false, "Sockets": false, "TeamValidator": false, "Ladders": false
1818
},
1919
"extends": "eslint:recommended",

app.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
*
3333
* Used to access the simulator itself.
3434
*
35-
* CommandParser - from command-parser.js
35+
* Chat - from chat.js
3636
*
37-
* Parses text commands like /me
37+
* Handles chat and parses chat commands like /me and /ban
3838
*
3939
* Sockets - from sockets.js
4040
*
@@ -122,7 +122,7 @@ delete process.send; // in case we're a child process
122122
global.Verifier = require('./verifier');
123123
Verifier.PM.spawn();
124124

125-
global.CommandParser = require('./command-parser');
125+
global.Chat = require('./chat');
126126

127127
global.Simulator = require('./simulator');
128128

@@ -136,7 +136,7 @@ if (Config.crashguard) {
136136
process.on('uncaughtException', err => {
137137
let crashMessage = require('./crashlogger')(err, 'The main process');
138138
if (crashMessage !== 'lockdown') return;
139-
let stack = CommandParser.escapeHTML(err.stack).split("\n").slice(0, 2).join("<br />");
139+
let stack = Chat.escapeHTML(err.stack).split("\n").slice(0, 2).join("<br />");
140140
if (!Rooms.global.lockdown) {
141141
if (Rooms.lobby) {
142142
Rooms.lobby.addRaw('<div class="broadcast-red"><b>THE SERVER HAS CRASHED:</b> ' + stack + '<br />Please restart the server.</div>');

chat-plugins/datasearch.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ exports.commands = {
9696
} else if (response.reply) {
9797
this.sendReplyBox(response.reply);
9898
} else if (response.dt) {
99-
CommandParser.commands.data.call(this, response.dt, room, user, connection, 'dt');
99+
Chat.commands.data.call(this, response.dt, room, user, connection, 'dt');
100100
}
101101
this.update();
102102
});
@@ -148,7 +148,7 @@ exports.commands = {
148148
} else if (response.reply) {
149149
this.sendReplyBox(response.reply);
150150
} else if (response.dt) {
151-
CommandParser.commands.data.call(this, response.dt, room, user, connection, 'dt');
151+
Chat.commands.data.call(this, response.dt, room, user, connection, 'dt');
152152
}
153153
this.update();
154154
});
@@ -176,7 +176,7 @@ exports.commands = {
176176
} else if (response.reply) {
177177
this.sendReplyBox(response.reply);
178178
} else if (response.dt) {
179-
CommandParser.commands.data.call(this, response.dt, room, user, connection, 'dt');
179+
Chat.commands.data.call(this, response.dt, room, user, connection, 'dt');
180180
}
181181
this.update();
182182
});
@@ -209,7 +209,7 @@ exports.commands = {
209209
} else if (response.reply) {
210210
this.sendReplyBox(response.reply);
211211
} else if (response.dt) {
212-
CommandParser.commands.data.call(this, response.dt, room, user, connection, 'dt');
212+
Chat.commands.data.call(this, response.dt, room, user, connection, 'dt');
213213
}
214214
this.update();
215215
});
@@ -484,7 +484,7 @@ function runDexsearch(target, cmd, canAll, message) {
484484
case '=': direction = 'equal'; break;
485485
}
486486
} else {
487-
return {reply: "No value given to compare with '" + CommandParser.escapeHTML(target) + "'."};
487+
return {reply: "No value given to compare with '" + Chat.escapeHTML(target) + "'."};
488488
}
489489
switch (toId(stat)) {
490490
case 'attack': stat = 'atk'; break;
@@ -495,13 +495,13 @@ function runDexsearch(target, cmd, canAll, message) {
495495
case 'spdef': stat = 'spd'; break;
496496
case 'speed': stat = 'spe'; break;
497497
}
498-
if (!(stat in allStats)) return {reply: "'" + CommandParser.escapeHTML(target) + "' did not contain a valid stat."};
498+
if (!(stat in allStats)) return {reply: "'" + Chat.escapeHTML(target) + "' did not contain a valid stat."};
499499
if (!orGroup.stats[stat]) orGroup.stats[stat] = {};
500500
if (orGroup.stats[stat][direction]) return {reply: "Invalid stat range for " + stat + "."};
501501
orGroup.stats[stat][direction] = num;
502502
continue;
503503
}
504-
return {reply: "'" + CommandParser.escapeHTML(target) + "' could not be found in any of the search categories."};
504+
return {reply: "'" + Chat.escapeHTML(target) + "' could not be found in any of the search categories."};
505505
}
506506
searches.push(orGroup);
507507
}
@@ -661,7 +661,7 @@ function runDexsearch(target, cmd, canAll, message) {
661661
results = Tools.shuffle(results).slice(0, randomOutput);
662662
}
663663

664-
let resultsStr = (message === "" ? message : "<font color=#999999>" + CommandParser.escapeHTML(message) + ":</font><br>");
664+
let resultsStr = (message === "" ? message : "<font color=#999999>" + Chat.escapeHTML(message) + ":</font><br>");
665665
if (results.length > 1) {
666666
if (showAll || results.length <= RESULTS_MAX_LENGTH + 5) {
667667
results.sort();
@@ -702,7 +702,7 @@ function runMovesearch(target, cmd, canAll, message) {
702702
let typeIndex = target.indexOf(' type');
703703
if (typeIndex >= 0) {
704704
target = target.charAt(0).toUpperCase() + target.substring(1, typeIndex);
705-
if (!(target in Tools.data.TypeChart)) return {reply: "Type '" + CommandParser.escapeHTML(target) + "' not found."};
705+
if (!(target in Tools.data.TypeChart)) return {reply: "Type '" + Chat.escapeHTML(target) + "' not found."};
706706
if (!searches['type']) searches['type'] = {};
707707
if ((searches['type'][target] && isNotSearch) || (searches['type'][target] === false && !isNotSearch)) return {reply: 'A search cannot both exclude and include a type.'};
708708
searches['type'][target] = !isNotSearch;
@@ -786,15 +786,15 @@ function runMovesearch(target, cmd, canAll, message) {
786786
case '=': direction = 'equal'; break;
787787
}
788788
} else {
789-
return {reply: "No value given to compare with '" + CommandParser.escapeHTML(target) + "'."};
789+
return {reply: "No value given to compare with '" + Chat.escapeHTML(target) + "'."};
790790
}
791791
let prop = targetParts[propSide];
792792
switch (toId(targetParts[propSide])) {
793793
case 'basepower': prop = 'basePower'; break;
794794
case 'bp': prop = 'basePower'; break;
795795
case 'acc': prop = 'accuracy'; break;
796796
}
797-
if (!(prop in allProperties)) return {reply: "'" + CommandParser.escapeHTML(target) + "' did not contain a valid property."};
797+
if (!(prop in allProperties)) return {reply: "'" + Chat.escapeHTML(target) + "' did not contain a valid property."};
798798
if (!searches['property']) searches['property'] = {};
799799
if (direction === 'equal') {
800800
if (searches['property'][prop]) return {reply: "Invalid property range for " + prop + "."};
@@ -845,7 +845,7 @@ function runMovesearch(target, cmd, canAll, message) {
845845
case 'evasiveness': target = 'evasion'; break;
846846
default: target = target.substr(7);
847847
}
848-
if (!(target in allBoosts)) return {reply: "'" + CommandParser.escapeHTML(target.substr(7)) + "' is not a recognized stat."};
848+
if (!(target in allBoosts)) return {reply: "'" + Chat.escapeHTML(target.substr(7)) + "' is not a recognized stat."};
849849
if (!searches['boost']) searches['boost'] = {};
850850
if ((searches['boost'][target] && isNotSearch) || (searches['boost'][target] === false && !isNotSearch)) return {reply: 'A search cannot both exclude and include a stat boost.'};
851851
searches['boost'][target] = !isNotSearch;
@@ -880,7 +880,7 @@ function runMovesearch(target, cmd, canAll, message) {
880880
continue;
881881
}
882882

883-
return {reply: "'" + CommandParser.escapeHTML(oldTarget) + "' could not be found in any of the search categories."};
883+
return {reply: "'" + Chat.escapeHTML(oldTarget) + "' could not be found in any of the search categories."};
884884
}
885885

886886
if (showAll && !Object.keys(searches).length && !targetMon) {
@@ -1017,7 +1017,7 @@ function runMovesearch(target, cmd, canAll, message) {
10171017
if (targetMon) {
10181018
resultsStr += "<font color=#999999>Matching moves found in learnset for</font> " + targetMon + ":<br>";
10191019
} else {
1020-
resultsStr += (message === "" ? message : "<font color=#999999>" + CommandParser.escapeHTML(message) + ":</font><br>");
1020+
resultsStr += (message === "" ? message : "<font color=#999999>" + Chat.escapeHTML(message) + ":</font><br>");
10211021
}
10221022
if (results.length > 0) {
10231023
if (showAll || results.length <= RESULTS_MAX_LENGTH + 5) {
@@ -1233,7 +1233,7 @@ function runItemsearch(target, cmd, canAll, message) {
12331233
}
12341234
}
12351235

1236-
let resultsStr = (message === "" ? message : "<font color=#999999>" + CommandParser.escapeHTML(message) + ":</font><br>");
1236+
let resultsStr = (message === "" ? message : "<font color=#999999>" + Chat.escapeHTML(message) + ":</font><br>");
12371237
if (foundItems.length > 0) {
12381238
if (showAll || foundItems.length <= RESULTS_MAX_LENGTH + 5) {
12391239
foundItems.sort();

chat-plugins/hangman.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,21 +142,21 @@ class Hangman extends Rooms.RoomGame {
142142
);
143143
}
144144

145-
if (this.hint) output += '<div>(Hint: ' + CommandParser.escapeHTML(this.hint) + ')</div>';
145+
if (this.hint) output += '<div>(Hint: ' + Chat.escapeHTML(this.hint) + ')</div>';
146146
output += '<p style="font-weight:bold;font-size:12pt;letter-spacing:3pt">' + wordString + '</p>';
147147
if (this.guesses.length) {
148148
if (this.letterGuesses.length) {
149149
output += 'Letters: ' + this.letterGuesses.map(g =>
150-
'<strong' + (g[1] === '1' ? '' : ' style="color: #DBA"') + '>' + CommandParser.escapeHTML(g[0]) + '</strong>'
150+
'<strong' + (g[1] === '1' ? '' : ' style="color: #DBA"') + '>' + Chat.escapeHTML(g[0]) + '</strong>'
151151
).join(', ');
152152
}
153153
if (result === 2) {
154-
output += '<br />Winner: ' + CommandParser.escapeHTML(this.lastGuesser);
154+
output += '<br />Winner: ' + Chat.escapeHTML(this.lastGuesser);
155155
} else if (this.guesses[this.guesses.length - 1].length === 1) {
156156
// last guess was a letter
157-
output += ' <small>&ndash; ' + CommandParser.escapeHTML(this.lastGuesser) + '</small>';
157+
output += ' <small>&ndash; ' + Chat.escapeHTML(this.lastGuesser) + '</small>';
158158
} else {
159-
output += '<br />Guessed: ' + this.guesses[this.guesses.length - 1] + ' <small>&ndash; ' + CommandParser.escapeHTML(this.lastGuesser) + '</small>';
159+
output += '<br />Guessed: ' + this.guesses[this.guesses.length - 1] + ' <small>&ndash; ' + Chat.escapeHTML(this.lastGuesser) + '</small>';
160160
}
161161
}
162162

0 commit comments

Comments
 (0)