Variable strings in JSON object

This commit is contained in:
Lucas Gabriel 2025-01-13 00:03:32 -03:00
parent 698f5eb6a0
commit 52f3f643c1
No known key found for this signature in database
GPG Key ID: D9B075FC6DC93985
5 changed files with 34 additions and 30 deletions

View File

@ -52,7 +52,7 @@ module.exports = (bot) => {
disable_web_page_preview: true,
reply_markup: JSON.stringify({
inline_keyboard: [
[{ text: Strings.varBack, callback_data: 'helpBack' }],
[{ text: Strings.varStrings.varBack, callback_data: 'helpBack' }],
]
})
};

View File

@ -10,11 +10,11 @@ async function getUserInfo(ctx) {
}
userInfo = Strings.userInfo
.replace('{userName}', `${ctx.from.first_name} ${lastName}` || Strings.unKnown)
.replace('{userId}', ctx.from.id || Strings.unKnown)
.replace('{userHandle}', ctx.from.username ? `@${ctx.from.username}` : Strings.varNone)
.replace('{userPremium}', ctx.from.is_premium ? Strings.varYes : Strings.varNo)
.replace('{userLang}', ctx.from.language_code || Strings.unKnown);
.replace('{userName}', `${ctx.from.first_name} ${lastName}` || Strings.varStrings.varUnknown)
.replace('{userId}', ctx.from.id || Strings.varStrings.varUnknown)
.replace('{userHandle}', ctx.from.username ? `@${ctx.from.username}` : Strings.varStrings.varStrings.varNone)
.replace('{userPremium}', ctx.from.is_premium ? Strings.varStrings.varYes : Strings.varStrings.varNo)
.replace('{userLang}', ctx.from.language_code || Strings.varStrings.varUnknown);
return userInfo;
}
@ -23,12 +23,12 @@ async function getChatInfo(ctx) {
const Strings = getStrings(ctx.from.language_code);
if (ctx.chat.type === 'group' || ctx.chat.type === 'supergroup') {
chatInfo = Strings.chatInfo
.replace('{chatId}', ctx.chat.id || Strings.unKnown)
.replace('{chatName}', ctx.chat.title || Strings.unKnown)
.replace('{chatHandle}', ctx.chat.username ? `@${ctx.chat.username}` : Strings.varNone)
.replace('{chatMembersCount}', await ctx.getChatMembersCount(ctx.chat.id || Strings.unKnown))
.replace('{chatType}', ctx.chat.type || Strings.unKnown)
.replace('{isForum}', ctx.chat.is_forum ? Strings.varYes : Strings.varNo);
.replace('{chatId}', ctx.chat.id || Strings.varStrings.varUnknown)
.replace('{chatName}', ctx.chat.title || Strings.varStrings.varUnknown)
.replace('{chatHandle}', ctx.chat.username ? `@${ctx.chat.username}` : Strings.varStrings.varStrings.varNone)
.replace('{chatMembersCount}', await ctx.getChatMembersCount(ctx.chat.id || Strings.varStrings.varUnknown))
.replace('{chatType}', ctx.chat.type || Strings.varStrings.varUnknown)
.replace('{isForum}', ctx.chat.is_forum ? Strings.varStrings.varYes : Strings.varStrings.varNo);
return chatInfo;
} else {

View File

@ -127,7 +127,7 @@ module.exports = (bot) => {
const trackName = track.name;
const artistName = track.artist['#text'];
const nowPlaying = track['@attr'] && track['@attr'].nowplaying ? Strings.varIs : Strings.varWas;
const nowPlaying = track['@attr'] && track['@attr'].nowplaying ? Strings.varStrings.varIs : Strings.varStrings.varWas;
const albumMbid = track.album.mbid;
let imageUrl = "";
@ -192,7 +192,7 @@ module.exports = (bot) => {
.replace("{plays}", `${num_plays}`);
} else {
message = message
.replace("{playCount}", Strings.varTo);
.replace("{playCount}", Strings.varStrings.varTo);
};
if (imageUrl) {

View File

@ -4,14 +4,16 @@
"botPrivacy": "Check out [this link](https://blog.lucmsilva.com/posts/lynx-privacy-policy) to read the bot's privacy policy.",
"botAbout": "*About the bot*\n\nThe bot base was originally created by [Lucas Gabriel (lucmsilva)](https://github.com/lucmsilva651), now maintained by several people.\n\nThe bot's purpose is to bring fun to your groups here on Telegram in a relaxed and simple way. The bot also features some very useful commands, which you can see using the help command (/help).\n\nSpecial thanks to @givfnz2 for his many contributions to the bot!\n\nSee the source code: [Click here to go to GitHub]({sourceLink})",
"aboutBot": "About the bot",
"unKnown": "Unknown",
"varYes": "Yes",
"varNo": "No",
"varTo": "to",
"varIs": "is",
"varWas": "was",
"varNone": "None",
"varBack": "Back",
"varStrings": {
"varYes": "Yes",
"varNo": "No",
"varTo": "to",
"varIs": "is",
"varWas": "was",
"varNone": "None",
"varUnknown": "Unknown",
"varBack": "Back"
},
"unexpectedErr": "Some unexpected error occurred during a bot action. Please report it to the developers.",
"errInvalidOption": "Whoops! Invalid option!",
"kickingMyself": "*Since you don't need me, I'll leave.*",

View File

@ -4,14 +4,16 @@
"botPrivacy": "Acesse [este link](https://blog.lucmsilva.com/posts/lynx-privacy-policy) para ler a política de privacidade do bot.",
"botAbout": "*Sobre o bot*\n\nA base deste bot foi feita originalmente por [Lucas Gabriel (lucmsilva)](https://github.com/lucmsilva651), agora sendo mantido por várias pessoas.\n\nA intenção do bot é trazer diversão para os seus grupos aqui no Telegram de uma maneira bem descontraida e simples. O bot também conta com alguns comandos bem úteis, que você consegue ver com o comando de ajuda (/help).\n\nAgradecimento especial ao @givfnz2 pelas suas várias contribuições ao bot!\n\nVeja o código fonte: [Clique aqui para ir ao GitHub]({sourceLink})",
"aboutBot": "Sobre o bot",
"unKnown": "Desconhecido",
"varYes": "Sim",
"varNo": "Não",
"varTo": "",
"varIs": "está",
"varWas": "estava",
"varNone": "Nenhum",
"varBack": "Voltar",
"varStrings": {
"varYes": "Sim",
"varNo": "Não",
"varTo": "",
"varIs": "está",
"varWas": "estava",
"varNone": "Nenhum",
"varUnknown": "Desconhecido",
"varBack": "Voltar"
},
"unexpectedErr": "Algum erro inesperado ocorreu durante uma ação do bot. Por favor, reporte aos desenvolvedores.\n\n{error}",
"errInvalidOption": "Ops! Opção inválida!",
"kickingMyself": "*Já que você não precisa de mim, vou sair daqui.*",