Skip to content

Commit

Permalink
Support multiline /(room|staff)intro
Browse files Browse the repository at this point in the history
This greatly simplifies the process of edition of room topics, as
it would previously require a workflow including beatification before
getting to work on it, and compression afterwards.
  • Loading branch information
Slayer95 committed May 29, 2016
1 parent 694b70f commit 3f5b6ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
21 changes: 11 additions & 10 deletions commands.js
Expand Up @@ -634,10 +634,10 @@ exports.commands = {
if (!target) {
if (!this.runBroadcast()) return;
if (!room.introMessage) return this.sendReply("This room does not have an introduction set.");
this.sendReply('|raw|<div class="infobox infobox-limited">' + room.introMessage + '</div>');
this.sendReply('|raw|<div class="infobox infobox-limited">' + room.introMessage.replace(/\n/g, '') + '</div>');
if (!this.broadcasting && user.can('declare', null, room)) {
this.sendReply('Source:');
this.sendReplyBox('<code>/roomintro ' + Tools.escapeHTML(room.introMessage) + '</code>');
this.sendReplyBox('<code>/roomintro ' + Tools.escapeHTML(room.introMessage).replace(/\n/g, '<br />') + '</code>');
}
return;
}
Expand All @@ -651,12 +651,12 @@ exports.commands = {
}
if (target.substr(0, 11) === '/roomintro ') target = target.substr(11);

room.introMessage = target;
room.introMessage = target.replace(/\r/g, '');
this.sendReply("(The room introduction has been changed to:)");
this.sendReply('|raw|<div class="infobox infobox-limited">' + target + '</div>');
this.sendReply('|raw|<div class="infobox infobox-limited">' + room.introMessage.replace(/\n/g, '') + '</div>');

this.privateModCommand("(" + user.name + " changed the roomintro.)");
this.logEntry(target);
this.logEntry(room.introMessage.replace(/\n/g, ''));

if (room.chatRoomData) {
room.chatRoomData.introMessage = room.introMessage;
Expand All @@ -683,10 +683,10 @@ exports.commands = {
if (!target) {
if (!this.can('mute', null, room)) return false;
if (!room.staffMessage) return this.sendReply("This room does not have a staff introduction set.");
this.sendReply('|raw|<div class="infobox">' + room.staffMessage + '</div>');
this.sendReply('|raw|<div class="infobox">' + room.staffMessage.replace(/\n/g, '') + '</div>');
if (user.can('ban', null, room)) {
this.sendReply('Source:');
this.sendReplyBox('<code>/staffintro ' + Tools.escapeHTML(room.staffMessage) + '</code>');
this.sendReplyBox('<code>/staffintro ' + Tools.escapeHTML(room.staffMessage).replace(/\n/g, '<br />') + '</code>');
}
return;
}
Expand All @@ -700,12 +700,12 @@ exports.commands = {
}
if (target.substr(0, 12) === '/staffintro ') target = target.substr(12);

room.staffMessage = target;
room.staffMessage = target.replace(/\r/g, '');
this.sendReply("(The staff introduction has been changed to:)");
this.sendReply('|raw|<div class="infobox">' + target + '</div>');
this.sendReply('|raw|<div class="infobox">' + target.replace(/\n/g, '') + '</div>');

this.privateModCommand("(" + user.name + " changed the staffintro.)");
this.logEntry(target);
this.logEntry(room.staffMessage.replace(/\n/g, ''));

if (room.chatRoomData) {
room.chatRoomData.staffMessage = room.staffMessage;
Expand Down Expand Up @@ -3046,4 +3046,5 @@ exports.commands = {

process.nextTick(() => {
CommandParser.multiLinePattern.register('>>>? ');
CommandParser.multiLinePattern.register('/(room|staff)(topic|intro) ');
});
4 changes: 2 additions & 2 deletions rooms.js
Expand Up @@ -1500,8 +1500,8 @@ let ChatRoom = (() => {
};
ChatRoom.prototype.getIntroMessage = function (user) {
let message = '';
if (this.introMessage) message += '\n|raw|<div class="infobox infobox-roomintro"><div' + (!this.isOfficial ? ' class="infobox-limited"' : '') + '>' + this.introMessage + '</div>';
if (this.staffMessage && user.can('mute', null, this)) message += (message ? '<br />' : '\n|raw|<div class="infobox">') + '(Staff intro:)<br /><div>' + this.staffMessage + '</div>';
if (this.introMessage) message += '\n|raw|<div class="infobox infobox-roomintro"><div' + (!this.isOfficial ? ' class="infobox-limited"' : '') + '>' + this.introMessage.replace(/\n/g, '') + '</div>';
if (this.staffMessage && user.can('mute', null, this)) message += (message ? '<br />' : '\n|raw|<div class="infobox">') + '(Staff intro:)<br /><div>' + this.staffMessage.replace(/\n/g, '') + '</div>';
if (this.modchat) {
message += (message ? '<br />' : '\n|raw|<div class="infobox">') + '<div class="broadcast-red">' +
'Must be rank ' + this.modchat + ' or higher to talk right now.' +
Expand Down

1 comment on commit 3f5b6ad

@Zarel
Copy link
Member

@Zarel Zarel commented on 3f5b6ad Sep 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed one:

a8b7e7e

Please sign in to comment.