Variable strings in JSON object

This commit is contained in:
Luquinhas 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) {