From b5e220b2840bb8126e8620290c30f8b2d2e89d71 Mon Sep 17 00:00:00 2001 From: Luquinhas Date: Fri, 10 Jan 2025 11:28:27 -0300 Subject: [PATCH] Put all strings of Last.fm on another JSON object --- src/commands/lastfm.js | 16 ++++++++-------- src/locales/english.json | 20 +++++++++++--------- src/locales/portuguese.json | 20 +++++++++++--------- 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/commands/lastfm.js b/src/commands/lastfm.js index 80ada6e..7ee0afd 100644 --- a/src/commands/lastfm.js +++ b/src/commands/lastfm.js @@ -66,7 +66,7 @@ module.exports = (bot) => { const lastUser = ctx.message.text.split(' ')[1]; if (!lastUser) { - return ctx.reply(Strings.lastFmNoUser, { + return ctx.reply(Strings.lastFm.noUser, { parse_mode: "Markdown", disable_web_page_preview: true, reply_to_message_id: ctx.message.message_id @@ -76,7 +76,7 @@ module.exports = (bot) => { users[userId] = lastUser; saveUsers(); - const message = Strings.lastFmUserSet.replace('{lastUser}', lastUser); + const message = Strings.lastFm.userHasBeenSet.replace('{lastUser}', lastUser); ctx.reply(message, { parse_mode: "Markdown", @@ -93,7 +93,7 @@ module.exports = (bot) => { const botInfo = await ctx.telegram.getMe(); if (!lastfmUser) { - return ctx.reply(Strings.lastFmNoSet, { + return ctx.reply(Strings.lastFm.noUserSet, { parse_mode: "Markdown", disable_web_page_preview: true, reply_to_message_id: ctx.message.message_id @@ -117,7 +117,7 @@ module.exports = (bot) => { const track = response.data.recenttracks.track[0]; if (!track) { - const noRecent = Strings.lastFmNoRecent.replace('{lastfmUser}', lastfmUser); + const noRecent = Strings.lastFm.noRecentTracks.replace('{lastfmUser}', lastfmUser); return ctx.reply(noRecent, { parse_mode: "Markdown", disable_web_page_preview: true, @@ -170,7 +170,7 @@ module.exports = (bot) => { }; } catch (err) { console.log(err) - const message = Strings.lastFmErr + const message = Strings.lastFm.apiErr .replace("{lastfmUser}", `[${lastfmUser}](${userUrl})`) .replace("{err}", err); ctx.reply(message, { @@ -180,7 +180,7 @@ module.exports = (bot) => { }); }; - let message = Strings.lastFmStatusFor + let message = Strings.lastFm.listeningTo .replace("{lastfmUser}", `[${lastfmUser}](${userUrl})`) .replace("{nowPlaying}", nowPlaying) .replace("{trackName}", `[${trackName}](${trackUrl})`) @@ -188,7 +188,7 @@ module.exports = (bot) => { if (`${num_plays}` !== "0" && `${num_plays}` !== "1" && `${num_plays}` !== "2" && `${num_plays}` !== "3") { message = message - .replace("{playCount}", Strings.lastFmPlayCount) + .replace("{playCount}", Strings.lastFm.playCount) .replace("{plays}", `${num_plays}`); } else { message = message @@ -211,7 +211,7 @@ module.exports = (bot) => { }; } catch (err) { const userUrl = `https://www.last.fm/user/${encodeURIComponent(lastfmUser)}`; - const message = Strings.lastFmErr + const message = Strings.lastFm.apiErr .replace("{lastfmUser}", `[${lastfmUser}](${userUrl})`) .replace("{err}", err); ctx.reply(message, { diff --git a/src/locales/english.json b/src/locales/english.json index 71f2b99..ce54062 100644 --- a/src/locales/english.json +++ b/src/locales/english.json @@ -38,13 +38,17 @@ "chatInfo": "*Chat info*\n\n*Name:* `{chatName}`\n*Chat ID:* `{chatId}`\n*Handle:* `{chatHandle}`\n*Type:* `{chatType}`\n*Members:* `{chatMembersCount}`\n*Is a forum:* `{isForum}`", "funEmojiResult": "*You rolled {emoji} and got* `{value}`*!*\nYou don't know what that means? Me neither!", "gifErr": "*Something went wrong while sending the GIF. Please try again later.*\n\n{err}", - "lastFmNoUser": "*Please provide a Last.fm username.*\nExample: `/setuser `", - "lastFmNoSet": "*You haven't set your Last.fm username yet.*\nUse the command /setuser to set.\n\nExample: `/setuser `", - "lastFmNoRecent": "*No recent tracks found for Last.fm user* `{lastfmUser}`*.*", - "lastFmUserSet": "*Your Last.fm username has been set to:* `{lastUser}`.", - "lastFmStatusFor": "{lastfmUser} *{nowPlaying} listening {playCount}*:\n\n{trackName} by {artistName}", - "lastFmPlayCount": "by the {plays}th time", - "lastFmErr": "*Error retrieving data for Last.fm user* {lastfmUser}.\n\n`{err}`", + "lastFm": { + "helpEntry": "Last.fm", + "helpDesc": "*Last.fm*\n\n- /lt | /lmu | /last | /lfm: Shows the last song from your Last.fm profile + the number of plays.\n- /setuser ``: Sets the user for the command above.", + "noUser": "*Please provide a Last.fm username.*\nExample: `/setuser `", + "noUserSet": "*You haven't set your Last.fm username yet.*\nUse the command /setuser to set.\n\nExample: `/setuser `", + "noRecentTracks": "*No recent tracks found for Last.fm user* `{lastfmUser}`*.*", + "userHasBeenSet": "*Your Last.fm username has been set to:* `{lastUser}`.", + "listeningTo": "{lastfmUser} *{nowPlaying} listening {playCount}*:\n\n{trackName} by {artistName}", + "playCount": "by the {plays}th time", + "apiErr": "*Error retrieving data for Last.fm user* {lastfmUser}.\n\n`{err}`" + }, "gitCurrentCommit": "*Current commit:* `{commitHash}`", "gitErrRetrievingCommit": "*Error retrieving commit:* {error}", "weatherStatus": { @@ -63,8 +67,6 @@ "interactiveEmojisDesc": "*Interactive emojis*\n\n- /dice: Roll a dice\n- /idice: Infinitely roll a colored dice\n- /slot: Try to combine the figures!\n- /ball: Try to kick the ball into the goal!\n- /bowling: Try to hit the pins!\n- /dart: Try to hit the target!", "ytDlp": "Video download", "ytDlpDesc": "*Video download*\n\n- /yt | /ytdl | /sdl | /dl | /video `