diff --git a/README.md b/README.md index dc32104..cdcbea6 100644 --- a/README.md +++ b/README.md @@ -14,15 +14,15 @@ First, [make a fork of this repo](https://github.com/lucmsilva651/lynx/fork), or ``` git clone https://github.com/lucmsilva651/lynx ``` -Next, go to the repository directory, create a ``Config.env`` file and put the content below: +Next, inside the repository directory, go to props folder and create a config.json file with the following content: ``` -TGBOT_TOKEN="0000000000:AAAaaAAaaaaAaAaaAAAaaaAaaaaAAAAAaaa" -TGBOT_ADMINS=[0000000000, 1111111111, 2222222222] -SW_KEY="aAaAAaaAAaAA_AAAAAaaAAaaAAaaAAAAAAaaAaaAaaAAaaAAaAaAAaaAAaaAAaAaA" +{ + "botToken": "0000000000:AAAaaAAaaaaAaAaaAAAaaaAaaaaAAAAAaaa", + "admins": [0000000000, 1111111111, 2222222222] +} ``` -- **TGBOT_TOKEN**: Put your bot token that you created at [@BotFather](https://t.me/botfather) at the variable ``TGBOT_TOKEN`` (as the example above). -- **TGBOT_ADMINS**: Put the ID of the people responsible for managing the bot (as the example above). They can use some administrative + exclusive commands on any group. -- **SW_KEY**: A API key to make a blocklist to banned SpamWatch users. You can refer to SpamWatch docs to create a API key for yourself. +- **botToken**: Put your bot token that you created at [@BotFather](https://t.me/botfather), as the example above. +- **admins**: Put the ID of the people responsible for managing the bot (as the example above). They can use some administrative + exclusive commands on any group. After editing the file, save all changes and run the bot with ``npm start``. 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); diff --git a/commands/start.js b/commands/start.js index b1db859..53b7441 100644 --- a/commands/start.js +++ b/commands/start.js @@ -1,8 +1,9 @@ -const Strings = require('../locales/english.json'); const resources = require('../props/resources.json'); +const { getStrings } = require('./checklang'); module.exports = (bot) => { bot.start((ctx) => { + const Strings = getStrings(ctx.from.language_code); ctx.replyWithPhoto( resources.lynxProfilePhoto, { caption: Strings.lynxWelcome, diff --git a/locales/portuguese.json b/locales/portuguese.json new file mode 100644 index 0000000..4ffb888 --- /dev/null +++ b/locales/portuguese.json @@ -0,0 +1,20 @@ +{ + "lynxWelcome": "*Olá! Eu sou o Lynx!*\nEu fui feito com amor por Lucas Gabriel (lucmsilva)!\n\n*Antes de usar, você precisará ler a política de privacidade (/privacy) para entender para onde seus dados vão ao usar este bot.\n\n*Além disso, você pode usar /help para mostrar os comandos do bot.", + "lynxHelp": "*Olá! Eu sou o Lynx!*\n\nSou um simples bot feito inteiramente do zero em Telegraf + Node.js por Lucas Gabriel (lucmsilva).\n\n*Alguns comandos para testar:*\n• */chatinfo* - manda algumas informações sobre o grupo\n• */customize* - customiza seus pronomes (WIP)\n• */furry* - checa se você é um furry\n• */gay* - checa se você é gay\n• */help* - manda essa mensagem\n• */privacy* - lê a política de privacidade\n• */random* - escolhe um número aleatório entre 0-10\n• */start* - Inicia o bot\n• */userinfo* - manda algumas informações sobre você\n\n*Veja o código fonte em:* [GitHub Repository](https://github.com/lucmsilva651/lynx)\n\nObrigado a todos os usuários, testers, contribuidores e outros. Sem vocês, talvez esse bot não seria possível ❤️", + "lynxPrivacy": "*Cheque o link abaixo para ler a política de privacidade do bot:*\n• https://blog.eleu.me/posts/lynx-privacy-policy", + "unKnown": "Desconhecido", + "varYes": "Sim", + "varNo": "Não", + "varNone": "Nenhum", + "noPermission": "Você não tem permissões para rodar esse comando.", + "privateOnly": "Esse comando deve ser utilizado apenas em chats privados, e não em grupos.", + "groupOnly": "Esse comando deve ser utilizado apenas em grupos, e não em chats privados.", + "isGay": "Sim, você é *gay*!", + "isNtGay": "Aahhh. Você não é gay!", + "isFurry": "Sim, você é um esquisito *furry*!", + "isNtFurry": "Aahhh. Você não é um furry!", + "randomNum": "*Número gerado (0-10):* `{number}`", + "userInfo": "*Informações do usuário*\n\n*Seu nome é:* `{userName}`\n*Seu username é:* `{userHandle}`\n*Seu ID é:* `{userId}`\n*Você é um bot:* `{isBot}`\n*Seu idioma:* `{userLang}`\n*Você é um usuário premium:* `{userPremium}`", + "chatInfo": "*Informações do grupo*\n\n*Nome do chat:* `{chatName}`\n*ID do chat:* `{chatId}`\n*Identificador:* `{chatHandle}`\n*Tipo de chat* `{chatType}`\n*Número de membros:* `{chatMembersCount}`\n*É um fórum:* `{isForum}`" + } + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 38aa271..e74d035 100644 --- a/package-lock.json +++ b/package-lock.json @@ -308,7 +308,6 @@ "version": "3.1.4", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.4.tgz", "integrity": "sha512-wjPBbFhtpJwmIeY2yP7QF+UKzPfltVGtfce1g/bB15/8vCGZj8uxD62b/b9M9/WVgme0NZudpownKN+c0plXlQ==", - "license": "MIT", "dependencies": { "chokidar": "^3.5.2", "debug": "^4",