From 9d020798903ef349ef27cb48685f57e20c78189c Mon Sep 17 00:00:00 2001 From: mattyatea Date: Sat, 4 Nov 2023 10:12:13 +0900 Subject: [PATCH] uhoize fix --- .../frontend/src/pages/settings/profile.vue | 2 +- packages/frontend/src/scripts/uhoize.ts | 24 +++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/frontend/src/pages/settings/profile.vue b/packages/frontend/src/pages/settings/profile.vue index 1ecde64d05..a5f1a15577 100644 --- a/packages/frontend/src/pages/settings/profile.vue +++ b/packages/frontend/src/pages/settings/profile.vue @@ -218,7 +218,7 @@ function save() { claimAchievement('markedAsCat'); } if (profile.isGorilla) { - claimAchievement('markedAsCat'); + claimAchievement('markedAsGorilla'); } } diff --git a/packages/frontend/src/scripts/uhoize.ts b/packages/frontend/src/scripts/uhoize.ts index 25d3760722..e0c5572802 100644 --- a/packages/frontend/src/scripts/uhoize.ts +++ b/packages/frontend/src/scripts/uhoize.ts @@ -1,8 +1,23 @@ +function uhoize(str) { + const punctuation = ['。', '!', '?', '.', '!', '?']; + let lines = str.split('\n'); + let voice = 'ウホ'; + return lines.map(line => { + if (Math.floor(Math.random() * 2) === 0) { + voice = 'ウホッ' + } else { + voice = 'ウホ' + } + let lastChar = line.trim().slice(-1); + if (punctuation.includes(lastChar)) { + let lineWithoutPunctuation = line.trim().slice(0, -1); + return lineWithoutPunctuation + voice + lastChar; + } else { + return line + voice; + } + }).join('\n'); +} /* - * SPDX-FileCopyrightText: syuilo and other misskey contributors - * SPDX-License-Identifier: AGPL-3.0-only - */ - export function uhoize(text) { const gorillaNoises = ['ウホ', 'ウホホ', 'ウホッ']; let result = ''; @@ -26,3 +41,4 @@ export function uhoize(text) { } return result; } +*/