From 484867f0b752964e9ede42d7a619fd8cb2e60a4d Mon Sep 17 00:00:00 2001 From: Massick <4ndyraul@gmail.com> Date: Thu, 26 Dec 2024 23:01:26 -0300 Subject: [PATCH] change default language for title --- src/middleware/actions.ts | 13 ++++++++----- src/middleware/novels.ts | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/middleware/actions.ts b/src/middleware/actions.ts index 0f5da1f..d228670 100644 --- a/src/middleware/actions.ts +++ b/src/middleware/actions.ts @@ -391,20 +391,22 @@ actions.action(/afm_\d+_\d+_\d+_\d+/i, async ctx => { const results = await getAnime(parseInt(animeId)) if (!results) return ctx.answerCbQuery('Anime not found').catch(e => logger.error(e)) const anime = results.Media - const englishTitle = anime.title.english ?? 'English title not found!' + const nativeTitle = anime.title.native + const romajiTitle = anime.title.romaji + const note = `Native: ${nativeTitle}\nRomaji: ${romajiTitle}\nAdded from the menu` await prisma.anime .upsert({ where: { name_userId: { - name: anime.title.romaji.trim(), + name: anime.title.english.trim(), userId: user } }, create: { - name: anime.title.romaji.trim(), + name: anime.title.english.trim(), season: parseInt(season), episode: parseInt(episode), - note: englishTitle + '\nAdded from the menu', + note, onAir: anime.nextAiringEpisode?.airingAt ? true : false, user: { connectOrCreate: { @@ -418,7 +420,8 @@ actions.action(/afm_\d+_\d+_\d+_\d+/i, async ctx => { } }, update: { - note: englishTitle + '\nUpdated from the menu', + note, + onAir: anime.nextAiringEpisode?.airingAt ? true : false, } }) .then(() => ctx.answerCbQuery('Anime added/updated!').catch(logger.error)) diff --git a/src/middleware/novels.ts b/src/middleware/novels.ts index 6653bf7..c30d5c6 100644 --- a/src/middleware/novels.ts +++ b/src/middleware/novels.ts @@ -691,12 +691,12 @@ novel.action(/nfm_\d+_\d+/i, async ctx => { .upsert({ where: { name_userId: { - name: novel.title.romaji.trim(), + name: novel.title.english.trim(), userId: user } }, create: { - name: novel.title.romaji.trim(), + name: novel.title.english.trim(), volume: 1, note, releasing: /releasing/i.test(novel.status) ? true : false,