Preact: Fix /nonotify and raw message parsing in PMs (#2565)
Some checks failed
Node.js CI / build (22.x) (push) Has been cancelled

---------

Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
This commit is contained in:
Aurastic 2025-12-07 13:32:54 +05:30 committed by GitHub
parent be3d1edcae
commit 53171f59ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 6 deletions

View File

@ -1295,7 +1295,7 @@ export class BattleLog {
case 'data-move':
return ['chat message-error', '[outdated code no longer supported]'];
case 'text':
return ['chat', BattleLog.parseMessage(target)];
return ['chat', BattleLog.parseMessage(target), true];
case 'error':
return ['chat message-error', formatText(target, true)];
case 'html':

View File

@ -139,16 +139,25 @@ export class ChatRoom extends PSRoom {
if (args[0] === 'c:') PS.lastMessageTime = args[1];
this.lastMessage = args;
this.joinLeave = null;
this.markUserActive(args[args[0] === 'c:' ? 2 : 1]);
const name = args[args[0] === 'c:' ? 2 : 1];
this.markUserActive(name);
if (this.tour) this.tour.joinLeave = null;
if (this.id.startsWith("dm-")) {
const fromUser = args[args[0] === 'c:' ? 2 : 1];
if (toID(fromUser) === PS.user.userid) break;
const message = args[args[0] === 'c:' ? 3 : 2];
this.notify({
title: `${this.title}`,
body: message,
});
const noNotify = this.log?.parseChatMessage(message, name, args[1])?.[2];
if (!noNotify) {
let textContent = message;
if (/^\/(log|raw|html|uhtml|uhtmlchange) /.test(message)) {
textContent = message.split(' ').slice(1).join(' ')
.replace(/<[^>]*?>/g, '');
}
this.notify({
title: `${this.title}`,
body: textContent,
});
}
} else {
this.subtleNotify();
}