Feat:ゴリラモード

This commit is contained in:
mattyatea 2023-11-02 16:51:03 +09:00
parent 10d38335f2
commit 5335e68bde
13 changed files with 108 additions and 8 deletions

View file

@ -0,0 +1,28 @@
/*
* SPDX-FileCopyrightText: syuilo and other misskey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
export function uhoize(text) {
const gorillaNoises = ['ウホ', 'ウホホ', 'ウホッ'];
let result = '';
let noiseIndex = 0;
for (let i = 0; i < text.length; i++) {
if (!(/[、。.,\/#!$%\^&\*;:{}=\-_`~()]/.test(text[i]))) {
if (/[^\x00-\x7F]/.test(text[i])) {
noiseIndex = Math.floor(Math.random() * 3);
const japaneseNoises = ['ウホ', 'ウホホ', 'ウホッ'];
result += japaneseNoises[noiseIndex];
} else {
noiseIndex = Math.floor(Math.random() * 2);
const englishNoises = ['uho', 'uhoho'];
result += englishNoises[noiseIndex];
}
}else{
result += text[i];
}
if (text.length*1.3 < result.length) return result
}
return result;
}