diff --git a/commands/checklang.js b/commands/checklang.js new file mode 100644 index 0000000..7d2a37a --- /dev/null +++ b/commands/checklang.js @@ -0,0 +1,11 @@ +function getStrings(languageCode) { + if (languageCode === 'pt-br') { + return require('../locales/portuguese.json'); + } else { + return require('../locales/english.json'); + } +} + +module.exports = { + getStrings + }; \ No newline at end of file diff --git a/commands/fun.js b/commands/fun.js index 881733d..96c47e9 100644 --- a/commands/fun.js +++ b/commands/fun.js @@ -1,7 +1,8 @@ -const Strings = require('../locales/english.json'); const resources = require('../props/resources.json'); +const { getStrings } = require('./checklang'); function furryFunction(ctx) { + const Strings = getStrings(ctx.from.language_code); if (Math.random() < 0.5 ? "yes" : "no" === "yes") { ctx.replyWithAnimation( resources.furryGif, { @@ -21,6 +22,7 @@ function furryFunction(ctx) { } function gayFunction(ctx) { + const Strings = getStrings(ctx.from.language_code); if (Math.random() < 0.5 ? "yes" : "no" === "yes") { ctx.replyWithAnimation( resources.gayFlag, { diff --git a/commands/getinfo.js b/commands/getinfo.js index b1748a3..14d812d 100644 --- a/commands/getinfo.js +++ b/commands/getinfo.js @@ -1,6 +1,6 @@ -const Strings = require('../locales/english.json'); const Config = require('../props/config.json'); const os = require('os'); +const { getStrings } = require('./checklang'); function formatUptime(uptime) { const hours = Math.floor(uptime / 3600); @@ -34,6 +34,7 @@ function getSystemInfo() { // Função para obter informações do usuário async function getUserInfo(ctx) { + const Strings = getStrings(ctx.from.language_code); let userInfoTemplate = Strings.userInfo; const userName = ctx.from.first_name || Strings.unKnown; @@ -56,6 +57,7 @@ async function getUserInfo(ctx) { // Função para obter informações do chat async function getChatInfo(ctx) { + const Strings = getStrings(ctx.from.language_code); if (ctx.chat.type === 'group' || ctx.chat.type === 'supergroup') { let chatInfoTemplate = Strings.chatInfo; diff --git a/commands/help.js b/commands/help.js index 7d2f7f1..8d384e4 100644 --- a/commands/help.js +++ b/commands/help.js @@ -1,8 +1,9 @@ -const Strings = require('../locales/english.json'); +const { getStrings } = require('./checklang'); const resources = require('../props/resources.json'); module.exports = (bot) => { bot.help((ctx) => { + const Strings = getStrings(ctx.from.language_code); ctx.replyWithPhoto( resources.lynxFullPhoto, { caption: Strings.lynxHelp, diff --git a/commands/privacy.js b/commands/privacy.js index acc6546..9177a62 100644 --- a/commands/privacy.js +++ b/commands/privacy.js @@ -1,7 +1,8 @@ -const Strings = require('../locales/english.json'); +const { getStrings } = require('./checklang'); module.exports = (bot) => { bot.command('privacy', (ctx) => { + const Strings = getStrings(ctx.from.language_code); ctx.reply( Strings.lynxPrivacy, { parse_mode: 'Markdown', diff --git a/commands/random.js b/commands/random.js index 17199e2..4fbc329 100644 --- a/commands/random.js +++ b/commands/random.js @@ -1,4 +1,4 @@ -const Strings = require('../locales/english.json'); +const { getStrings } = require('./checklang'); function getRandomInt(max) { return Math.floor(Math.random() * max); @@ -6,6 +6,7 @@ function getRandomInt(max) { module.exports = (bot) => { bot.command('random', (ctx) => { + const Strings = getStrings(ctx.from.language_code); const randomValue = getRandomInt(11); const randomVStr = Strings.randomNum.replace('{number}', randomValue);