Skip to content

Commit 6c05eb0

Browse files
committed
fix: More translation fixes
1 parent a3492fc commit 6c05eb0

File tree

4 files changed

+26
-19
lines changed

4 files changed

+26
-19
lines changed

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
## Version 0.26.3
44
1. Fix quest notification
55
1. Fix home page translations
6+
1. Fix legend user notification
7+
1. Fix legendary card draw notification
8+
1. Fix winstreak notification
69

710
## Version 0.26.2
811
1. Fix battle log (again)

src/base/chat/legend.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,23 @@ wrap(() => {
1616
category: 'Legendary User',
1717
});
1818

19-
eventManager.on('preChat:getMessageAuto', function legend({message: text}) {
20-
const index = text.indexOf(' has just reached ');
21-
if (this.canceled || !~index) return;
19+
const events = ['chat-new-legend'];
20+
eventManager.on('preChat:getMessageAuto', function legend(data) {
21+
const message = JSON.parse(JSON.parse(data.message).args);
22+
if (this.canceled || !events.includes(message[0])) return;
2223
const handling = setting.value();
2324
const friendsOnly = friends.value();
2425
if (handling === 'Chat' && !friendsOnly) return; // All default
2526
const hidden = handling === 'Hidden';
2627
this.canceled = hidden || handling === 'Toast';
2728
if (hidden) return;
28-
const user = text.substring(0, index);
29+
const user = message[1];
2930
if (friendsOnly && !fn.isFriend(user)) {
3031
this.canceled = true;
3132
return;
3233
}
3334
fn.toast({
34-
text,
35+
text: translateFromServerJson(data.message),
3536
css: {
3637
color: 'yellow',
3738
footer: {color: 'white'},

src/base/chat/legendary.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,32 @@ wrap(() => {
2222
return null;
2323
}
2424

25+
const events = ['chat-legendary-notification', 'chat-legendary-shiny-notification'];
2526
eventManager.on('preChat:getMessageAuto', function drawAnnouncement(data) {
27+
const message = JSON.parse(JSON.parse(data.message).args);
28+
if (this.canceled || !events.includes(message[0])) return;
2629
const setting = settings.value('underscript.announcement.draws');
27-
const index = data.message.indexOf(' has just obtained ');
28-
if (this.canceled || setting === 'chat' || !~index) return;
30+
if (setting === 'chat') return;
2931
const both = setting === 'both';
3032
this.canceled = !both;
3133
if (both || setting === 'toast') {
32-
const owner = data.message.substring(0, index);
33-
const card = data.message.substring(index + 19, data.message.length - 2);
34+
const owner = message[1];
35+
const card = message[2];
3436

3537
const last = getToast(owner);
3638
if (last) {
37-
const text = `${owner} has just obtained ${last.cards.join(', ')} and ${card} !`;
38-
last.setText(text);
39-
last.time = Date.now(); // This toast is still relevant!
4039
last.cards.push(card);
40+
message[2] = last.cards.join(', ');
41+
last.setText(translateFromServerJson(JSON.stringify({args: JSON.stringify(message)})));
42+
last.time = Date.now(); // This toast is still relevant!
4143
return;
4244
}
4345
if (toasts[toastIndex]) { // Close any old toast
4446
toasts[toastIndex].close();
4547
}
46-
48+
4749
const toast = fn.toast({
48-
text: data.message,
50+
text: translateFromServerJson(data.message),
4951
css: {
5052
color: 'yellow',
5153
footer: {color: 'white'},

src/base/chat/winstreak.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@ wrap(() => {
3838
//return parseInt(amt, 10) >= settings.value('underscript.winstreak.count');
3939
return true;
4040
}
41-
eventManager.on('preChat:getMessageAuto', function winstreaks({message: text}) {
42-
if (this.canceled || !~text.indexOf('game winning streak !')) return;
41+
const events = ['chat-user-ws', 'chat-user-ws-stop'];
42+
eventManager.on('preChat:getMessageAuto', function winstreaks(data) {
43+
const message = JSON.parse(JSON.parse(data.message).args);
44+
if (this.canceled || !events.includes(message[0])) return;
4345
const handling = settings.value('underscript.winstreak');
4446
if (handling === 'Chat' && !friendsOnly()) return; // All default
4547
this.canceled = handling !== 'Chat' && handling !== 'Both';
4648
if (handling === 'Hidden') return;
47-
const results = text.match(regex);
48-
const username = results[1] || results[4];
49-
const streak = results[2] || results[5];
49+
const username = message[message.length - 2];
50+
const streak = message[message.length - 1];
5051
if (!checkFriend(username) || !checkCount(streak)) {
5152
this.canceled = true;
5253
return;

0 commit comments

Comments
 (0)