diff --git a/server/chat-commands/info.ts b/server/chat-commands/info.ts
index 0d9b5c3411..9b52c85dc8 100644
--- a/server/chat-commands/info.ts
+++ b/server/chat-commands/info.ts
@@ -2535,18 +2535,23 @@ export const commands: ChatCommands = {
if (!room.settings.quotes?.length) return this.errorReply(`This room has no quotes.`);
this.runBroadcast();
const {quote, date, userid} = room.settings.quotes[Math.floor(Math.random() * room.settings.quotes.length)];
- const formatted = quote.split('\n').map(item => Chat.formatText(item)).join('
');
const time = Chat.toTimestamp(new Date(date), {human: true});
- const attribution = toID(target) === 'showauthor' ? `
Added by ${userid} on ${time}` : '';
- return this.sendReplyBox(`${formatted}
` + attribution);
+ const attribution = toID(target) === 'showauthor' ? `
Added by ${userid} on ${time}` : '';
+ return this.sendReplyBox(`${Chat.formatText(quote).replace(/\n/g, '
')}${attribution}`);
},
randquotehelp: [`/randquote [showauthor] - Show a random quote from the room. Add 'showauthor' to see who added it and when.`],
addquote: 'quote',
quote(target, room, user) {
room = this.requireRoom();
+ if (!room.persist) {
+ return this.errorReply("This command is unavailable in temporary rooms.");
+ }
target = target.trim();
this.checkCan('mute', null, room);
+ if (!target) {
+ return this.parse(`/help quote`);
+ }
if (!room.settings.quotes) room.settings.quotes = [];
if (this.filter(target) !== target) {
return this.errorReply(`Invalid quote.`);
@@ -2554,16 +2559,17 @@ export const commands: ChatCommands = {
if (room.settings.quotes.filter(item => item.quote === target).length) {
return this.errorReply(`"${target}" is already quoted in this room.`);
}
- if (target.length > 300) {
- return this.errorReply(`Your quote is too long.`);
+ if (target.length > 8192) {
+ return this.errorReply(`Your quote cannot exceed 8192 characters.`);
}
if (room.settings.quotes.length >= 100) {
return this.errorReply(`This room already has 100 quotes, which is the maximum.`);
}
room.settings.quotes.push({userid: user.id, quote: target, date: Date.now()});
room.saveSettings();
- this.privateModAction(`${user.name} added the quote "${target}"`);
- return this.modlog(`ADDQUOTE`, null, target);
+ const collapsedQuote = target.replace(/\n/g, ' ');
+ this.privateModAction(`${user.name} added a new quote: "${collapsedQuote}".`);
+ return this.modlog(`ADDQUOTE`, null, collapsedQuote);
},
quotehelp: [`/quote [quote] - Adds [quote] to the room's quotes. Requires: % @ # &`],
@@ -2572,6 +2578,9 @@ export const commands: ChatCommands = {
const [idx, roomid] = Utils.splitFirst(target, ',');
const targetRoom = roomid ? Rooms.search(roomid) : room;
if (!targetRoom) return this.errorReply(`Invalid room.`);
+ if (!targetRoom.persist) {
+ return this.errorReply("This command is unavailable in temporary rooms.");
+ }
this.room = targetRoom;
this.checkCan('mute', null, targetRoom);
if (!targetRoom.settings.quotes?.length) return this.errorReply(`This room has no quotes.`);
@@ -2583,17 +2592,21 @@ export const commands: ChatCommands = {
return this.errorReply(`Quote not found.`);
}
const [removed] = targetRoom.settings.quotes.splice(index - 1, 1);
- this.privateModAction(`${user.name} removed quote ${index}: "${removed.quote}" (originally added by ${removed.userid})`);
- this.modlog(`REMOVEQUOTE`, null, removed.quote);
- return targetRoom.saveSettings();
+ const collapsedQuote = target.replace(/\n/g, ' ');
+ this.privateModAction(`${user.name} removed quote indexed at ${index}: "${collapsedQuote}" (originally added by ${removed.userid}).`);
+ this.modlog(`REMOVEQUOTE`, null, collapsedQuote);
+ targetRoom.saveSettings();
+ if (roomid) this.parse(`/join view-quotes-${targetRoom.roomid}`);
},
removequotehelp: [`/removequote [index] - Removes the quote from the room's quotes. Requires: % @ # &`],
+ viewquotes: 'quotes',
quotes(target, room) {
const targetRoom = target ? Rooms.search(target) : room;
if (!targetRoom) return this.errorReply(`Invalid room.`);
return this.parse(`/join view-quotes-${targetRoom.roomid}`);
},
+ quoteshelp: [`/quotes [room] - Shows all quotes for [room]. Defaults the room the command is used in.`],
approvallog(target, room, user) {
room = this.requireRoom();
@@ -2770,23 +2783,25 @@ export const pages: PageTable = {
},
quotes(args, user) {
const room = this.requireRoom();
+ this.title = `[Quotes]`;
// allow it for users if they can access the room
if (!user.inRooms.has(room.roomid) && room.settings.isPrivate && !user.isStaff) {
return this.errorReply(`Access denied.`);
}
let buffer = ``;
+ buffer += ``;
if (!room.settings.quotes?.length) {
return `${buffer}
This room has no quotes.
`;
}
- buffer = `${buffer}Quotes on ${room.title}: (${room.settings.quotes.length})
`;
- for (const entry of room.settings.quotes) {
- const index = room.settings.quotes.indexOf(entry) + 1;
- const {quote, userid, date} = entry;
- buffer += `${index}: ${Chat.collapseLineBreaksHTML(Chat.formatText(quote))}`;
- buffer += `
Added by ${userid} on ${Chat.toTimestamp(new Date(date), {human: true})}`;
+ buffer += `
Quotes for ${room.title} (${room.settings.quotes.length}):
`;
+ for (const [i, quoteObj] of room.settings.quotes.entries()) {
+ const index = i + 1;
+ const {quote, userid, date} = quoteObj;
+ buffer += `
${index}: ${Chat.formatText(quote).replace(/\n/g, '
')}`;
+ buffer += `
Added by ${userid} on ${Chat.toTimestamp(new Date(date), {human: true})}`;
if (user.can('mute', null, room)) {
- buffer += `
`;
+ buffer += `
`;
}
buffer += `
`;
}
@@ -2798,7 +2813,7 @@ export const pages: PageTable = {
process.nextTick(() => {
Dex.includeData();
Chat.multiLinePattern.register(
- '/htmlbox', '/addquote', '!htmlbox', '/addhtmlbox', '/addrankhtmlbox', '/adduhtml',
+ '/htmlbox', '/quote', '/addquote', '!htmlbox', '/addhtmlbox', '/addrankhtmlbox', '/adduhtml',
'/changeuhtml', '/addrankuhtmlbox', '/changerankuhtmlbox'
);
});