mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-10-01 23:32:02 -05:00
Add support for a /nonotify message type (#1280)
This commit is contained in:
committed by
Guangcong Luo
parent
ae52ee2414
commit
a208645936
@@ -1578,6 +1578,10 @@
|
||||
|
||||
var isHighlighted = userid !== app.user.get('userid') && this.getHighlight(message);
|
||||
var parsedMessage = MainMenuRoom.parseChatMessage(message, name, ChatRoom.getTimestamp('chat', msgTime), isHighlighted);
|
||||
if (typeof parsedMessage === 'object' && 'noNotify' in parsedMessage) {
|
||||
mayNotify = mayNotify && !parsedMessage.noNotify;
|
||||
parsedMessage = parsedMessage.message;
|
||||
}
|
||||
if (!$.isArray(parsedMessage)) parsedMessage = [parsedMessage];
|
||||
for (var i = 0; i < parsedMessage.length; i++) {
|
||||
if (!parsedMessage[i]) continue;
|
||||
|
||||
@@ -144,6 +144,11 @@
|
||||
var autoscroll = ($chatFrame.scrollTop() + 60 >= $chat.height() - $chatFrame.height());
|
||||
|
||||
var parsedMessage = MainMenuRoom.parseChatMessage(message, name, ChatRoom.getTimestamp('pms'), false, $chat);
|
||||
var mayNotify = true;
|
||||
if (typeof parsedMessage === 'object' && 'noNotify' in parsedMessage) {
|
||||
mayNotify = !parsedMessage.noNotify;
|
||||
parsedMessage = parsedMessage.message;
|
||||
}
|
||||
if (!$.isArray(parsedMessage)) parsedMessage = [parsedMessage];
|
||||
for (var i = 0; i < parsedMessage.length; i++) {
|
||||
if (!parsedMessage[i]) continue;
|
||||
@@ -156,7 +161,7 @@
|
||||
app.curSideRoom.addPM(name, message, target);
|
||||
}
|
||||
|
||||
if (!isSelf && textContent) {
|
||||
if (mayNotify && !isSelf && textContent) {
|
||||
this.notifyOnce("PM from " + name, "\"" + textContent + "\"", 'pm');
|
||||
}
|
||||
|
||||
@@ -996,6 +1001,8 @@
|
||||
return '';
|
||||
case 'raw':
|
||||
return '<div class="chat">' + BattleLog.sanitizeHTML(target) + '</div>';
|
||||
case 'nonotify':
|
||||
return {message: '<div class="chat">' + BattleLog.sanitizeHTML(target) + '</div>', noNotify: true};
|
||||
default:
|
||||
// Not a command or unsupported. Parsed as a normal chat message.
|
||||
if (!name) {
|
||||
|
||||
@@ -64,6 +64,7 @@ class BattleLog {
|
||||
if (kwArgs && kwArgs.silent) return;
|
||||
let divClass = 'chat';
|
||||
let divHTML = '';
|
||||
let noNotify: boolean | undefined;
|
||||
switch (args[0]) {
|
||||
case 'chat': case 'c': case 'c:':
|
||||
let battle = this.scene && this.scene.battle;
|
||||
@@ -83,8 +84,8 @@ class BattleLog {
|
||||
}
|
||||
if (window.app && app.ignore && app.ignore[toUserid(name)] && ' +\u2605\u2606'.includes(rank)) return;
|
||||
let isHighlighted = window.app && app.rooms && app.rooms[battle!.roomid].getHighlight(message);
|
||||
[divClass, divHTML] = this.parseChatMessage(message, name, '', isHighlighted);
|
||||
if (isHighlighted) {
|
||||
[divClass, divHTML, noNotify] = this.parseChatMessage(message, name, '', isHighlighted);
|
||||
if (!noNotify && isHighlighted) {
|
||||
let notifyTitle = "Mentioned by " + name + " in " + battle!.roomid;
|
||||
app.rooms[battle!.roomid].notifyOnce(notifyTitle, "\"" + message + "\"", 'highlight');
|
||||
}
|
||||
@@ -435,7 +436,9 @@ class BattleLog {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
parseChatMessage(message: string, name: string, timestamp: string, isHighlighted?: boolean) {
|
||||
parseChatMessage(
|
||||
message: string, name: string, timestamp: string, isHighlighted?: boolean
|
||||
): [string, string, boolean?] {
|
||||
let showMe = !(BattleLog.prefs('chatformatting') || {}).hideme;
|
||||
let group = ' ';
|
||||
if (!/[A-Za-z0-9]/.test(name.charAt(0))) {
|
||||
@@ -516,6 +519,8 @@ class BattleLog {
|
||||
return ['', ''];
|
||||
case 'raw':
|
||||
return ['chat', BattleLog.sanitizeHTML(target)];
|
||||
case 'nonotify':
|
||||
return ['chat', BattleLog.sanitizeHTML(target), true];
|
||||
default:
|
||||
// Not a command or unsupported. Parsed as a normal chat message.
|
||||
if (!name) {
|
||||
|
||||
Reference in New Issue
Block a user