From 79091e697f01df261fb0990c97bb6ef58d8409a9 Mon Sep 17 00:00:00 2001 From: Lucas Gabriel Date: Tue, 15 Apr 2025 00:47:35 -0300 Subject: [PATCH 1/9] Update README.md (#38) --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a154166..7e58761 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # Kowalski (Node.js Telegram Bot) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md) -![GitHub License](https://img.shields.io/github/license/ABOCN/TelegramBot) - +[![GitHub License](https://img.shields.io/github/license/ABOCN/TelegramBot)](https://github.com/abocn/TelegramBot/blob/main/LICENSE) +[![CodeQL](https://github.com/abocn/TelegramBot/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/abocn/TelegramBot/actions/workflows/github-code-scanning/codeql) +[![Dependabot Updates](https://github.com/abocn/TelegramBot/actions/workflows/dependabot/dependabot-updates/badge.svg)](https://github.com/abocn/TelegramBot/actions/workflows/dependabot/dependabot-updates) Kowalski is a a simple Telegram bot made in Node.js. - You can find Kowalski at [@KowalskiNodeBot](https://t.me/KowalskiNodeBot) on Telegram. From f4d4f75eee18bc24dd4272c1321d88d692339c9d Mon Sep 17 00:00:00 2001 From: Lucas Gabriel Date: Tue, 15 Apr 2025 00:51:10 -0300 Subject: [PATCH 2/9] Update README.md (#39) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7e58761..6f485e6 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![GitHub License](https://img.shields.io/github/license/ABOCN/TelegramBot)](https://github.com/abocn/TelegramBot/blob/main/LICENSE) [![CodeQL](https://github.com/abocn/TelegramBot/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/abocn/TelegramBot/actions/workflows/github-code-scanning/codeql) [![Dependabot Updates](https://github.com/abocn/TelegramBot/actions/workflows/dependabot/dependabot-updates/badge.svg)](https://github.com/abocn/TelegramBot/actions/workflows/dependabot/dependabot-updates) + Kowalski is a a simple Telegram bot made in Node.js. - You can find Kowalski at [@KowalskiNodeBot](https://t.me/KowalskiNodeBot) on Telegram. From 5f178cb807c3bf94fe49c166eb248118ddc9a350 Mon Sep 17 00:00:00 2001 From: Luquinhas Date: Tue, 15 Apr 2025 00:55:12 -0300 Subject: [PATCH 3/9] LICENSE update --- LICENSE | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index ae3e4ae..2562540 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ BSD 3-Clause License -Copyright (c) 2024, Lucas Gabriel +Copyright (c) 2024-2025, Lucas Gabriel , +ABOCN and all contributors Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: From 958a61ae1112d841f45d59737cf7215bdc884176 Mon Sep 17 00:00:00 2001 From: Luquinhas Date: Tue, 15 Apr 2025 01:06:26 -0300 Subject: [PATCH 4/9] Update README.md again --- README.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 6f485e6..9be172f 100644 --- a/README.md +++ b/README.md @@ -11,24 +11,20 @@ Kowalski is a a simple Telegram bot made in Node.js. ## Self-host requirements -- Node.js 20 or newer (you can also use [Bun](https://bun.sh)) +> [!IMPORTANT] +> You will only need all of them if you are not running it dockerized. Read ["Running with Docker"](#running-with-docker) for more information. + +- Node.js 23 or newer (you can also use [Bun](https://bun.sh)) - A Telegram bot (create one at [@BotFather](https://t.me/botfather)) - FFmpeg (only for the `/yt` command) - Docker and Docker Compose (only required for Docker setup) -## Run it yourself, develop or contribute with Kowalski +## Running locally (non-Docker setup) First, clone the repo with Git: ```bash -git clone https://github.com/ABOCN/TelegramBot -``` - -And now, init the submodules with these commands (this is very important): - -```bash -cd TelegramBot -git submodule update --init --recursive +git clone --recurse-submodules https://github.com/ABOCN/TelegramBot ``` Next, inside the repository directory, create a `config.env` file with some content, which you can see the [example .env file](config.env.example) to fill info with. To see the meaning of each one, see [the Functions section](#configenv-functions). @@ -82,6 +78,8 @@ If you prefer to use Docker directly, you can use these instructions instead. ## config.env Functions - **botSource**: Put the link to your bot source code. +- **botPrivacy**: Put the link to your bot privacy policy. +- **maxRetries**: Maximum number of retries for a failing command on Kowalski. Default is 5. If the limit is hit, the bot will crash past this number. - **botToken**: Put your bot token that you created at [@BotFather](https://t.me/botfather). - **botAdmins**: Put the ID of the people responsible for managing the bot. They can use some administrative + exclusive commands on any group. - **lastKey**: Last.fm API key, for use on `lastfm.js` functions, like see who is listening to what song and etc. From 924ca1aae45424edb1d55528c3fa9f5ec76e1011 Mon Sep 17 00:00:00 2001 From: Luquinhas Date: Tue, 15 Apr 2025 01:06:50 -0300 Subject: [PATCH 5/9] Add variable bot privacy policy link + change config.env.example style --- config.env.example | 13 ++++++++++--- src/commands/main.js | 5 +++-- src/locales/english.json | 2 +- src/locales/portuguese.json | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/config.env.example b/config.env.example index 9773d37..452211b 100644 --- a/config.env.example +++ b/config.env.example @@ -1,5 +1,12 @@ -botSource = "https://github.com/change-this/to-your-repo/" -botToken = "InsertYourBotTokenHere" -botAdmins = 0000000000, 00000000, 00000000 +# links for source and privacy +botPrivacy = "https://blog.lucmsilva.com/posts/lynx-privacy-policy" +botSource = "https://github.com/ABOCN/TelegramBot" + +# insert token here +botToken = "" + +# misc (botAdmins isnt a array here!) +maxRetries = 9999 +botAdmins = 00000000, 00000000, 00000000 lastKey = "InsertYourLastFmApiKeyHere" weatherKey = "InsertYourWeatherDotComApiKeyHere" \ No newline at end of file diff --git a/src/commands/main.js b/src/commands/main.js index 6333296..4341b56 100644 --- a/src/commands/main.js +++ b/src/commands/main.js @@ -16,8 +16,9 @@ module.exports = (bot) => { bot.command('privacy', spamwatchMiddleware, async (ctx) => { const Strings = getStrings(ctx.from.language_code); - ctx.reply( - Strings.botPrivacy, { + const message = Strings.botPrivacy.replace("{botPrivacy}", process.env.botPrivacy); + + ctx.reply(message, { parse_mode: 'Markdown', disable_web_page_preview: true, reply_to_message_id: ctx.message.message_id diff --git a/src/locales/english.json b/src/locales/english.json index b2fb10a..2a143b9 100644 --- a/src/locales/english.json +++ b/src/locales/english.json @@ -1,7 +1,7 @@ { "botWelcome": "*Hello! I'm {botName}!*\nI was made with love by some nerds who really love programming!\n\n*By using {botName}, you affirm that you have read to and agree with the privacy policy (/privacy). This helps you understand where your data goes when using this bot.*\n\nAlso, you can use /help to see the bot commands!", "botHelp": "*Hey, I'm {botName}, a simple bot made entirely from scratch in Telegraf and Node.js by some nerds who really love programming.*\n\nClick on the buttons below to see which commands you can use!\n", - "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]({botPrivacy}) 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", "varStrings": { diff --git a/src/locales/portuguese.json b/src/locales/portuguese.json index 6b492f2..07872cc 100644 --- a/src/locales/portuguese.json +++ b/src/locales/portuguese.json @@ -1,7 +1,7 @@ { "botWelcome": "*Olá! Eu sou o {botName}!*\n\n*Ao usar o {botName}, você afirma que leu e concorda com a política de privacidade (/privacy). Isso ajuda você a entender onde seus dados vão ao usar este bot.*\n\nAlém disso, você pode usar /help para ver os meus comandos!", "botHelp": "*Oi, eu sou o {botName}, um bot simples feito do zero em Telegraf e Node.js por uns nerds que gostam de programação.*\n\nVeja o código fonte: [Clique aqui para ir ao GitHub]({sourceLink})\n\nClique nos botões abaixo para ver quais comandos você pode usar!\n", - "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]({botPrivacy}) 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", "varStrings": { From 80a0bc08ad8933e6bdd616df8f74bfbd8be45ecb Mon Sep 17 00:00:00 2001 From: Luquinhas Date: Tue, 15 Apr 2025 01:10:30 -0300 Subject: [PATCH 6/9] Update README again --- README.md | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9be172f..44c2b74 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,9 @@ After editing the file, save all changes and run the bot with ``npm start``. > [!IMPORTANT] > Please complete the above steps to prepare your local copy for building. You do not need to install FFmpeg on your host system. +> [!NOTE] +> Using the `-d` flag when running causes Kowalski to run in the background. If you're just playing around or testing, you may not want to use this flag. + You can also run Kowalski using Docker, which simplifies the setup process. Make sure you have Docker and Docker Compose installed. ### Using Docker Compose @@ -51,9 +54,6 @@ You can also run Kowalski using Docker, which simplifies the setup process. Make docker compose up -d ``` -> [!NOTE] -> The `-d` flag causes Kowalski to run in the background. If you're just playing around, you may not want to use this flag. - ### Using Docker Run If you prefer to use Docker directly, you can use these instructions instead. @@ -72,10 +72,9 @@ If you prefer to use Docker directly, you can use these instructions instead. docker run -d --name kowalski --restart unless-stopped -v $(pwd)/config.env:/usr/src/app/config.env:ro kowalski ``` -> [!NOTE] -> The `-d` flag causes Kowalski to run in the background. If you're just playing around, you may not want to use this flag. - ## config.env Functions +> [!IMPORTANT] +> Take care of your ``config.env`` file, as it is so much important and needs to be secret (like your passwords), as anyone can do whatever they want to the bot with this token! - **botSource**: Put the link to your bot source code. - **botPrivacy**: Put the link to your bot privacy policy. @@ -85,10 +84,6 @@ If you prefer to use Docker directly, you can use these instructions instead. - **lastKey**: Last.fm API key, for use on `lastfm.js` functions, like see who is listening to what song and etc. - **weatherKey**: Weather.com API key, used for the `/weather` command. -## Note - -- Take care of your ``config.env`` file, as it is so much important and needs to be secret (like your passwords), as anyone can do whatever they want to the bot with this token! - ## Troubleshooting ### YouTube Downloading From 31cfc01f2f9bb72def1da6997ca59680a5fbfde6 Mon Sep 17 00:00:00 2001 From: Luquinhas Date: Tue, 15 Apr 2025 19:12:21 -0300 Subject: [PATCH 7/9] Update all references to lib-spamwatch --- .gitmodules | 4 ++-- src/commands/animal.js | 4 ++-- src/commands/codename.js | 4 ++-- src/commands/crew.js | 4 ++-- src/commands/fun.js | 4 ++-- src/commands/gsmarena.js | 4 ++-- src/commands/help.js | 4 ++-- src/commands/http.js | 4 ++-- src/commands/info.js | 4 ++-- src/commands/lastfm.js | 4 ++-- src/commands/main.js | 4 ++-- src/commands/modarchive.js | 4 ++-- src/commands/ponyapi.js | 4 ++-- src/commands/quotes.js | 4 ++-- src/commands/randompony.js | 4 ++-- src/commands/weather.js | 4 ++-- src/commands/youtube.js | 4 ++-- src/plugins/lib-spamwatch | 1 - src/spamwatch | 1 + 19 files changed, 35 insertions(+), 35 deletions(-) delete mode 160000 src/plugins/lib-spamwatch create mode 160000 src/spamwatch diff --git a/.gitmodules b/.gitmodules index 1eb51e4..cf3ce05 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "src/plugins/lib-spamwatch"] - path = src/plugins/lib-spamwatch +[submodule "src/spamwatch"] + path = src/spamwatch url = https://github.com/ABOCN/TelegramBot-SpamWatch diff --git a/src/commands/animal.js b/src/commands/animal.js index 5355df1..204015d 100644 --- a/src/commands/animal.js +++ b/src/commands/animal.js @@ -1,7 +1,7 @@ const Resources = require('../props/resources.json'); const { getStrings } = require('../plugins/checklang.js'); -const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js'); -const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch); +const { isOnSpamWatch } = require('../spamwatch/spamwatch.js'); +const spamwatchMiddleware = require('../spamwatch/Middleware.js')(isOnSpamWatch); const axios = require("axios"); module.exports = (bot) => { diff --git a/src/commands/codename.js b/src/commands/codename.js index 4f23137..220f511 100644 --- a/src/commands/codename.js +++ b/src/commands/codename.js @@ -1,7 +1,7 @@ const Resources = require('../props/resources.json'); const { getStrings } = require('../plugins/checklang.js'); -const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js'); -const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch); +const { isOnSpamWatch } = require('../spamwatch/spamwatch.js'); +const spamwatchMiddleware = require('../spamwatch/Middleware.js')(isOnSpamWatch); const axios = require('axios'); async function getDeviceList() { diff --git a/src/commands/crew.js b/src/commands/crew.js index 52a3703..f754843 100644 --- a/src/commands/crew.js +++ b/src/commands/crew.js @@ -1,6 +1,6 @@ const { getStrings } = require('../plugins/checklang.js'); -const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js'); -const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch); +const { isOnSpamWatch } = require('../spamwatch/spamwatch.js'); +const spamwatchMiddleware = require('../spamwatch/Middleware.js')(isOnSpamWatch); const os = require('os'); const { exec } = require('child_process'); const { error } = require('console'); diff --git a/src/commands/fun.js b/src/commands/fun.js index 6fc0bba..b80696d 100644 --- a/src/commands/fun.js +++ b/src/commands/fun.js @@ -1,7 +1,7 @@ const Resources = require('../props/resources.json'); const { getStrings } = require('../plugins/checklang.js'); -const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js'); -const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch); +const { isOnSpamWatch } = require('../spamwatch/spamwatch.js'); +const spamwatchMiddleware = require('../spamwatch/Middleware.js')(isOnSpamWatch); function sendRandomReply(ctx, gifUrl, textKey) { const Strings = getStrings(ctx.from.language_code); diff --git a/src/commands/gsmarena.js b/src/commands/gsmarena.js index 6f5a01a..64b3932 100644 --- a/src/commands/gsmarena.js +++ b/src/commands/gsmarena.js @@ -4,8 +4,8 @@ // With some help from GPT (I don't really like AI but whatever) // If this were a kang, I would not be giving credits to him! -const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js'); -const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch); +const { isOnSpamWatch } = require('../spamwatch/spamwatch.js'); +const spamwatchMiddleware = require('../spamwatch/Middleware.js')(isOnSpamWatch); const axios = require('axios'); const { parse } = require('node-html-parser'); diff --git a/src/commands/help.js b/src/commands/help.js index ab9e601..163af25 100644 --- a/src/commands/help.js +++ b/src/commands/help.js @@ -1,6 +1,6 @@ const { getStrings } = require('../plugins/checklang.js'); -const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js'); -const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch); +const { isOnSpamWatch } = require('../spamwatch/spamwatch.js'); +const spamwatchMiddleware = require('../spamwatch/Middleware.js')(isOnSpamWatch); async function sendHelpMessage(ctx, isEditing) { const Strings = getStrings(ctx.from.language_code); diff --git a/src/commands/http.js b/src/commands/http.js index 13bd2ea..672a7c0 100644 --- a/src/commands/http.js +++ b/src/commands/http.js @@ -1,7 +1,7 @@ const Resources = require('../props/resources.json'); const { getStrings } = require('../plugins/checklang.js'); -const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js'); -const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch); +const { isOnSpamWatch } = require('../spamwatch/spamwatch.js'); +const spamwatchMiddleware = require('../spamwatch/Middleware.js')(isOnSpamWatch); const axios = require('axios'); module.exports = (bot) => { diff --git a/src/commands/info.js b/src/commands/info.js index b1c2c0b..f0c6354 100644 --- a/src/commands/info.js +++ b/src/commands/info.js @@ -1,6 +1,6 @@ const { getStrings } = require('../plugins/checklang.js'); -const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js'); -const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch); +const { isOnSpamWatch } = require('../spamwatch/spamwatch.js'); +const spamwatchMiddleware = require('../spamwatch/Middleware.js')(isOnSpamWatch); async function getUserInfo(ctx) { const Strings = getStrings(ctx.from.language_code); diff --git a/src/commands/lastfm.js b/src/commands/lastfm.js index 1f15f5a..ec6d126 100644 --- a/src/commands/lastfm.js +++ b/src/commands/lastfm.js @@ -2,8 +2,8 @@ const Resources = require('../props/resources.json'); const fs = require('fs'); const axios = require('axios'); const { getStrings } = require('../plugins/checklang.js'); -const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js'); -const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch); +const { isOnSpamWatch } = require('../spamwatch/spamwatch.js'); +const spamwatchMiddleware = require('../spamwatch/Middleware.js')(isOnSpamWatch); const scrobbler_url = Resources.lastFmApi; const api_key = process.env.lastKey; diff --git a/src/commands/main.js b/src/commands/main.js index 4341b56..6f36d64 100644 --- a/src/commands/main.js +++ b/src/commands/main.js @@ -1,6 +1,6 @@ const { getStrings } = require('../plugins/checklang.js'); -const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js'); -const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch); +const { isOnSpamWatch } = require('../spamwatch/spamwatch.js'); +const spamwatchMiddleware = require('../spamwatch/Middleware.js')(isOnSpamWatch); module.exports = (bot) => { bot.start(spamwatchMiddleware, async (ctx) => { diff --git a/src/commands/modarchive.js b/src/commands/modarchive.js index 86d3c99..35f2d7d 100644 --- a/src/commands/modarchive.js +++ b/src/commands/modarchive.js @@ -3,8 +3,8 @@ const axios = require('axios'); const fs = require('fs'); const path = require('path'); const { getStrings } = require('../plugins/checklang.js'); -const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js'); -const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch); +const { isOnSpamWatch } = require('../spamwatch/spamwatch.js'); +const spamwatchMiddleware = require('../spamwatch/Middleware.js')(isOnSpamWatch); async function downloadModule(moduleId) { try { diff --git a/src/commands/ponyapi.js b/src/commands/ponyapi.js index a002714..8f1239c 100644 --- a/src/commands/ponyapi.js +++ b/src/commands/ponyapi.js @@ -1,7 +1,7 @@ const Resources = require('../props/resources.json'); const { getStrings } = require('../plugins/checklang.js'); -const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js'); -const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch); +const { isOnSpamWatch } = require('../spamwatch/spamwatch.js'); +const spamwatchMiddleware = require('../spamwatch/Middleware.js')(isOnSpamWatch); const axios = require("axios"); function capitalizeFirstLetter(string) { diff --git a/src/commands/quotes.js b/src/commands/quotes.js index e73e70e..859af57 100644 --- a/src/commands/quotes.js +++ b/src/commands/quotes.js @@ -1,7 +1,7 @@ // const Resources = require('../props/resources.json'); // const { getStrings } = require('../plugins/checklang.js'); -// const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js'); -// const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch); +// const { isOnSpamWatch } = require('../spamwatch/spamwatch.js'); +// const spamwatchMiddleware = require('../spamwatch/Middleware.js')(isOnSpamWatch); // const escape = require('markdown-escape'); // const axios = require('axios'); diff --git a/src/commands/randompony.js b/src/commands/randompony.js index 814e41a..b935504 100644 --- a/src/commands/randompony.js +++ b/src/commands/randompony.js @@ -1,7 +1,7 @@ const Resources = require('../props/resources.json'); const { getStrings } = require('../plugins/checklang.js'); -const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js'); -const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch); +const { isOnSpamWatch } = require('../spamwatch/spamwatch.js'); +const spamwatchMiddleware = require('../spamwatch/Middleware.js')(isOnSpamWatch); const axios = require("axios"); module.exports = (bot) => { diff --git a/src/commands/weather.js b/src/commands/weather.js index 3818dad..ad8a5f0 100644 --- a/src/commands/weather.js +++ b/src/commands/weather.js @@ -5,8 +5,8 @@ const Resources = require('../props/resources.json'); const axios = require('axios'); const { getStrings } = require('../plugins/checklang.js'); -const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js'); -const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch); +const { isOnSpamWatch } = require('../spamwatch/spamwatch.js'); +const spamwatchMiddleware = require('../spamwatch/Middleware.js')(isOnSpamWatch); const statusEmojis = { 0: '⛈', 1: '⛈', 2: '⛈', 3: '⛈', 4: '⛈', 5: '🌨', 6: '🌨', 7: '🌨', diff --git a/src/commands/youtube.js b/src/commands/youtube.js index 2442f95..35be412 100644 --- a/src/commands/youtube.js +++ b/src/commands/youtube.js @@ -1,6 +1,6 @@ const { getStrings } = require('../plugins/checklang.js'); -const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js'); -const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch); +const { isOnSpamWatch } = require('../spamwatch/spamwatch.js'); +const spamwatchMiddleware = require('../spamwatch/Middleware.js')(isOnSpamWatch); const { execFile } = require('child_process'); const os = require('os'); const fs = require('fs'); diff --git a/src/plugins/lib-spamwatch b/src/plugins/lib-spamwatch deleted file mode 160000 index 8d35b7e..0000000 --- a/src/plugins/lib-spamwatch +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8d35b7ec4cffb48df8d1f59485b32e2484ae64e7 diff --git a/src/spamwatch b/src/spamwatch new file mode 160000 index 0000000..b71b3b9 --- /dev/null +++ b/src/spamwatch @@ -0,0 +1 @@ +Subproject commit b71b3b9eab0f172c038674fc6739fce9199ad3e0 From ad5b3c3f48a5437c28b68ebda24b9f28b9215341 Mon Sep 17 00:00:00 2001 From: Luquinhas Date: Tue, 15 Apr 2025 19:38:17 -0300 Subject: [PATCH 8/9] Fix git not found on docker image and fix path for spamwatch plugin --- Dockerfile | 2 +- src/bot.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 56b5b32..473f9b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM node:20-slim # Install ffmpeg and other deps -RUN apt-get update && apt-get install -y ffmpeg && apt-get clean && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y ffmpeg git && apt-get clean && rm -rf /var/lib/apt/lists/* WORKDIR /usr/src/app diff --git a/src/bot.js b/src/bot.js index 472bc10..d66b8e2 100644 --- a/src/bot.js +++ b/src/bot.js @@ -1,7 +1,7 @@ const { Telegraf } = require('telegraf'); const path = require('path'); const fs = require('fs'); -const { isOnSpamWatch } = require('./plugins/lib-spamwatch/spamwatch.js'); +const { isOnSpamWatch } = require('./spamwatch/spamwatch.js'); require('@dotenvx/dotenvx').config({ path: "config.env" }); require('./plugins/ytdlp-wrapper.js'); // require('./plugins/termlogger.js'); From e252a976968fca534a409d65dbcf429956b04bce Mon Sep 17 00:00:00 2001 From: Giovani Finazzi <53719063+GiovaniFZ@users.noreply.github.com> Date: Tue, 15 Apr 2025 19:39:52 -0300 Subject: [PATCH 9/9] fix: username on phone details (#40) --- src/commands/gsmarena.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/commands/gsmarena.js b/src/commands/gsmarena.js index 64b3932..23478c3 100644 --- a/src/commands/gsmarena.js +++ b/src/commands/gsmarena.js @@ -193,14 +193,18 @@ function extractMetaData(meta, key) { return line ? line.split('"')[1] : ""; } +function getUsername(ctx){ + let userName = String(ctx.from.first_name); + if(userName.includes("<") && userName.includes(">")) { + userName = userName.replaceAll("<", "").replaceAll(">", ""); + } + return userName; +} + module.exports = (bot) => { bot.command(['d', 'device'], spamwatchMiddleware, async (ctx) => { const userId = ctx.from.id; - let userName = String(ctx.from.first_name); - - if(userName.includes("<") && userName.includes(">")) { - userName = userName.replaceAll("<", "").replaceAll(">", ""); - } + const userName = getUsername(ctx); const phone = ctx.message.text.split(" ").slice(1).join(" "); if (!phone) { @@ -228,7 +232,7 @@ module.exports = (bot) => { bot.action(/details:(.+):(.+)/, async (ctx) => { const url = ctx.match[1]; const userId = parseInt(ctx.match[2]); - const userName = ctx.from.first_name; + const userName = getUsername(ctx); const callbackQueryUserId = ctx.update.callback_query.from.id;