mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 04:39:57 +00:00
Variable strings in JSON object
This commit is contained in:
parent
698f5eb6a0
commit
52f3f643c1
@ -52,7 +52,7 @@ module.exports = (bot) => {
|
|||||||
disable_web_page_preview: true,
|
disable_web_page_preview: true,
|
||||||
reply_markup: JSON.stringify({
|
reply_markup: JSON.stringify({
|
||||||
inline_keyboard: [
|
inline_keyboard: [
|
||||||
[{ text: Strings.varBack, callback_data: 'helpBack' }],
|
[{ text: Strings.varStrings.varBack, callback_data: 'helpBack' }],
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
@ -10,11 +10,11 @@ async function getUserInfo(ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
userInfo = Strings.userInfo
|
userInfo = Strings.userInfo
|
||||||
.replace('{userName}', `${ctx.from.first_name} ${lastName}` || Strings.unKnown)
|
.replace('{userName}', `${ctx.from.first_name} ${lastName}` || Strings.varStrings.varUnknown)
|
||||||
.replace('{userId}', ctx.from.id || Strings.unKnown)
|
.replace('{userId}', ctx.from.id || Strings.varStrings.varUnknown)
|
||||||
.replace('{userHandle}', ctx.from.username ? `@${ctx.from.username}` : Strings.varNone)
|
.replace('{userHandle}', ctx.from.username ? `@${ctx.from.username}` : Strings.varStrings.varStrings.varNone)
|
||||||
.replace('{userPremium}', ctx.from.is_premium ? Strings.varYes : Strings.varNo)
|
.replace('{userPremium}', ctx.from.is_premium ? Strings.varStrings.varYes : Strings.varStrings.varNo)
|
||||||
.replace('{userLang}', ctx.from.language_code || Strings.unKnown);
|
.replace('{userLang}', ctx.from.language_code || Strings.varStrings.varUnknown);
|
||||||
|
|
||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
@ -23,12 +23,12 @@ async function getChatInfo(ctx) {
|
|||||||
const Strings = getStrings(ctx.from.language_code);
|
const Strings = getStrings(ctx.from.language_code);
|
||||||
if (ctx.chat.type === 'group' || ctx.chat.type === 'supergroup') {
|
if (ctx.chat.type === 'group' || ctx.chat.type === 'supergroup') {
|
||||||
chatInfo = Strings.chatInfo
|
chatInfo = Strings.chatInfo
|
||||||
.replace('{chatId}', ctx.chat.id || Strings.unKnown)
|
.replace('{chatId}', ctx.chat.id || Strings.varStrings.varUnknown)
|
||||||
.replace('{chatName}', ctx.chat.title || Strings.unKnown)
|
.replace('{chatName}', ctx.chat.title || Strings.varStrings.varUnknown)
|
||||||
.replace('{chatHandle}', ctx.chat.username ? `@${ctx.chat.username}` : Strings.varNone)
|
.replace('{chatHandle}', ctx.chat.username ? `@${ctx.chat.username}` : Strings.varStrings.varStrings.varNone)
|
||||||
.replace('{chatMembersCount}', await ctx.getChatMembersCount(ctx.chat.id || Strings.unKnown))
|
.replace('{chatMembersCount}', await ctx.getChatMembersCount(ctx.chat.id || Strings.varStrings.varUnknown))
|
||||||
.replace('{chatType}', ctx.chat.type || Strings.unKnown)
|
.replace('{chatType}', ctx.chat.type || Strings.varStrings.varUnknown)
|
||||||
.replace('{isForum}', ctx.chat.is_forum ? Strings.varYes : Strings.varNo);
|
.replace('{isForum}', ctx.chat.is_forum ? Strings.varStrings.varYes : Strings.varStrings.varNo);
|
||||||
|
|
||||||
return chatInfo;
|
return chatInfo;
|
||||||
} else {
|
} else {
|
||||||
|
@ -127,7 +127,7 @@ module.exports = (bot) => {
|
|||||||
|
|
||||||
const trackName = track.name;
|
const trackName = track.name;
|
||||||
const artistName = track.artist['#text'];
|
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;
|
const albumMbid = track.album.mbid;
|
||||||
|
|
||||||
let imageUrl = "";
|
let imageUrl = "";
|
||||||
@ -192,7 +192,7 @@ module.exports = (bot) => {
|
|||||||
.replace("{plays}", `${num_plays}`);
|
.replace("{plays}", `${num_plays}`);
|
||||||
} else {
|
} else {
|
||||||
message = message
|
message = message
|
||||||
.replace("{playCount}", Strings.varTo);
|
.replace("{playCount}", Strings.varStrings.varTo);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (imageUrl) {
|
if (imageUrl) {
|
||||||
|
@ -4,14 +4,16 @@
|
|||||||
"botPrivacy": "Check out [this link](https://blog.lucmsilva.com/posts/lynx-privacy-policy) to read the bot's privacy policy.",
|
"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})",
|
"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",
|
"aboutBot": "About the bot",
|
||||||
"unKnown": "Unknown",
|
"varStrings": {
|
||||||
"varYes": "Yes",
|
"varYes": "Yes",
|
||||||
"varNo": "No",
|
"varNo": "No",
|
||||||
"varTo": "to",
|
"varTo": "to",
|
||||||
"varIs": "is",
|
"varIs": "is",
|
||||||
"varWas": "was",
|
"varWas": "was",
|
||||||
"varNone": "None",
|
"varNone": "None",
|
||||||
"varBack": "Back",
|
"varUnknown": "Unknown",
|
||||||
|
"varBack": "Back"
|
||||||
|
},
|
||||||
"unexpectedErr": "Some unexpected error occurred during a bot action. Please report it to the developers.",
|
"unexpectedErr": "Some unexpected error occurred during a bot action. Please report it to the developers.",
|
||||||
"errInvalidOption": "Whoops! Invalid option!",
|
"errInvalidOption": "Whoops! Invalid option!",
|
||||||
"kickingMyself": "*Since you don't need me, I'll leave.*",
|
"kickingMyself": "*Since you don't need me, I'll leave.*",
|
||||||
|
@ -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.",
|
"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})",
|
"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",
|
"aboutBot": "Sobre o bot",
|
||||||
"unKnown": "Desconhecido",
|
"varStrings": {
|
||||||
"varYes": "Sim",
|
"varYes": "Sim",
|
||||||
"varNo": "Não",
|
"varNo": "Não",
|
||||||
"varTo": "",
|
"varTo": "",
|
||||||
"varIs": "está",
|
"varIs": "está",
|
||||||
"varWas": "estava",
|
"varWas": "estava",
|
||||||
"varNone": "Nenhum",
|
"varNone": "Nenhum",
|
||||||
"varBack": "Voltar",
|
"varUnknown": "Desconhecido",
|
||||||
|
"varBack": "Voltar"
|
||||||
|
},
|
||||||
"unexpectedErr": "Algum erro inesperado ocorreu durante uma ação do bot. Por favor, reporte aos desenvolvedores.\n\n{error}",
|
"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!",
|
"errInvalidOption": "Ops! Opção inválida!",
|
||||||
"kickingMyself": "*Já que você não precisa de mim, vou sair daqui.*",
|
"kickingMyself": "*Já que você não precisa de mim, vou sair daqui.*",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user