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

@ -16,6 +16,8 @@ import { defaultStore } from '@/store';
import { mixEmoji } from '@/scripts/emojiKitchen/emojiMixer';
import MkRuby from "@/components/global/MkRuby.vue";
import { nyaize as doNyaize } from '@/scripts/nyaize.js';
import { uhoize as doUhoize } from '@/scripts/uhoize.js';
import {ID, Instance} from "misskey-js/built/entities.js";
const QUOTE_STYLE = `
display: block;
@ -62,12 +64,41 @@ type MfmProps = {
text: string;
plain?: boolean;
nowrap?: boolean;
author?: Misskey.entities.UserLite;
author?: {
id: ID;
username: string;
host: string | null;
name: string | null;
onlineStatus: 'online' | 'active' | 'offline' | 'unknown';
avatarUrl: string;
avatarBlurhash: string;
avatarDecorations: {
id: ID;
url: string;
angle?: number;
flipH?: boolean;
}[];
emojis: {
name: string;
url: string;
}[];
instance?: {
name: Instance['name'];
softwareName: Instance['softwareName'];
softwareVersion: Instance['softwareVersion'];
iconUrl: Instance['iconUrl'];
faviconUrl: Instance['faviconUrl'];
themeColor: Instance['themeColor'];
};
isGorilla?: boolean;
isCat?: boolean;
isBot?: boolean;};
i?: Misskey.entities.UserLite | null;
isNote?: boolean;
emojiUrls?: string[];
rootScale?: number;
nyaize: boolean | 'account';
uhoize: boolean | 'account';
parsedNodes?: mfm.MfmNode[] | null;
};
@ -75,7 +106,8 @@ type MfmProps = {
export default function(props: MfmProps) {
const isNote = props.isNote ?? true;
const shouldNyaize = props.nyaize ? props.nyaize === 'account' ? props.author?.isCat : false : false;
const shouldUhoize = props.nyaize ? props.nyaize === 'account' ? props.author?.isGorilla : false : false;
console.log(shouldUhoize, props.nyaize,props.author?.isGorilla)
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (props.text == null || props.text === '') return;
@ -93,15 +125,18 @@ export default function(props: MfmProps) {
* @param ast MFM AST
* @param scale How times large the text is
* @param disableNyaize Whether nyaize is disabled or not
* @param disableUhoize
*/
const genEl = (ast: mfm.MfmNode[], scale: number, disableNyaize = false) => ast.map((token): VNode | string | (VNode | string)[] => {
const genEl = (ast: mfm.MfmNode[], scale: number, disableNyaize = false, disableUhoize = false) => ast.map((token): VNode | string | (VNode | string)[] => {
switch (token.type) {
case 'text': {
let text = token.props.text.replace(/(\r\n|\n|\r)/g, '\n');
if (!disableNyaize && shouldNyaize) {
text = doNyaize(text);
}
if (!disableUhoize && shouldUhoize) {
text = doUhoize(text);
}
if (!props.plain) {
const res: (VNode | string)[] = [];
for (const t of text.split('\n')) {

View file

@ -105,7 +105,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #label>{{ i18n.ts.advancedSettings }}</template>
<div class="_gaps_m">
<MkSwitch v-model="profile.isCat">{{ i18n.ts.flagAsCat }}<template #caption>{{ i18n.ts.flagAsCatDescription }}</template></MkSwitch>
<MkSwitch :disabled="profile.isGorilla" v-model="profile.isCat">{{ i18n.ts.flagAsCat }}<template #caption>{{ i18n.ts.flagAsCatDescription }}</template></MkSwitch>
<MkSwitch :disabled="profile.isCat" v-model="profile.isGorilla">{{ i18n.ts.flagAsGorilla }}<template #caption>{{ i18n.ts.flagAsGorillaDescription }}</template></MkSwitch>
<MkSwitch v-model="profile.isBot">{{ i18n.ts.flagAsBot }}<template #caption>{{ i18n.ts.flagAsBotDescription }}</template></MkSwitch>
</div>
</MkFolder>
@ -154,6 +155,7 @@ const profile = reactive({
lang: $i.lang,
isBot: $i.isBot,
isCat: $i.isCat,
isGorilla: $i.isGorilla,
});
watch(() => profile, () => {
@ -206,6 +208,7 @@ function save() {
lang: profile.lang || null,
isBot: !!profile.isBot,
isCat: !!profile.isCat,
isGorilla: !!profile.isGorilla,
});
claimAchievement('profileFilled');
if (profile.name === 'syuilo' || profile.name === 'しゅいろ') {
@ -214,6 +217,9 @@ function save() {
if (profile.isCat) {
claimAchievement('markedAsCat');
}
if (profile.isGorilla) {
claimAchievement('markedAsCat');
}
}
function changeAvatar(ev) {

View file

@ -265,6 +265,11 @@ export const ACHIEVEMENT_BADGES = {
bg: 'linear-gradient(0deg, rgb(187 183 59), rgb(255 143 77))',
frame: 'bronze',
},
'markedAsGorilla': {
img: '/fluent-emoji/1f98D.png',
bg: 'linear-gradient(0deg, rgba(55,0,0,1) 0%, rgba(107,5,5,1) 59%, rgba(158,6,6,1) 100%)',
frame: 'bronze',
},
'following1': {
img: '/fluent-emoji/2618.png',
bg: 'linear-gradient(0deg, rgb(59 187 116), rgb(199 211 102))',

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;
}