Made the bot more generic now

This commit is contained in:
Luquinhas 2025-01-10 10:40:18 -03:00
parent c63efe5e67
commit ad27a25d1f
No known key found for this signature in database
GPG key ID: D9B075FC6DC93985
8 changed files with 24 additions and 15 deletions

View file

@ -31,9 +31,10 @@ const loadCommands = () => {
};
const startBot = async () => {
const botInfo = await bot.telegram.getMe();
console.log(`${botInfo.first_name} is running...`);
try {
await bot.launch();
console.log('Bot is running...');
restartCount = 0;
} catch (error) {
console.error('Failed to start bot:', error.message);

View file

@ -31,7 +31,9 @@ module.exports = (bot) => {
bot.command("about", spamwatchMiddleware, async (ctx) => {
const Strings = getStrings(ctx.from.language_code);
ctx.reply(Strings.botAbout, {
const aboutMsg = Strings.botAbout.replace("{sourceLink}", `${process.env.botSource}`);
ctx.reply(aboutMsg, {
parse_mode: 'Markdown',
disable_web_page_preview: true,
reply_to_message_id: ctx.message.message_id

View file

@ -90,6 +90,7 @@ module.exports = (bot) => {
const Strings = getStrings(ctx.from.language_code);
const lastfmUser = users[userId];
const genericImg = "https://lastfm.freetls.fastly.net/i/u/300x300/2a96cbd8b46e442fc41c2b86b821562f.png";
const botInfo = await ctx.telegram.getMe();
if (!lastfmUser) {
return ctx.reply(Strings.lastFmNoSet, {
@ -109,7 +110,7 @@ module.exports = (bot) => {
limit: 1
},
headers: {
'User-Agent': "kowalski-@KowalskiNodeBot-node-telegram-bot"
'User-Agent': `@${botInfo.username}-node-telegram-bot`
}
});
@ -159,7 +160,7 @@ module.exports = (bot) => {
format: 'json',
},
headers: {
'User-Agent': "kowalski-@KowalskiNodeBot-node-telegram-bot"
'User-Agent': `@${botInfo.username}-node-telegram-bot`
}
});
num_plays = response_plays.data.track.userplaycount;

View file

@ -5,7 +5,10 @@ const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(is
module.exports = (bot) => {
bot.start(spamwatchMiddleware, async (ctx) => {
const Strings = getStrings(ctx.from.language_code);
ctx.reply(Strings.botWelcome, {
const botInfo = await ctx.telegram.getMe();
const startMsg = Strings.botWelcome.replace('{botName}', botInfo.first_name);
ctx.reply(startMsg, {
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id
});

View file

@ -1,8 +1,8 @@
{
"botWelcome": "*Hello! I am Kowalski!*\nI was made with love by some nerds who really love programming!\n\n*Before using, you need to read the privacy policy (/privacy) to understand where your data goes when using this bot.*\n\nAlso, you can use /help to see the bot commands!\n\n*Special thanks to @givfnz2 for his many contributions to the bot!*",
"botHelp": "*Hey, I'm Kowalski, 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",
"botWelcome": "*Hello! I am {botName}!*\nI was made with love by some nerds who really love programming!\n\n*Before using, you need to read the privacy policy (/privacy) to understand where your data goes when using this bot.*\n\nAlso, you can use /help to see the bot commands!\n\n*Special thanks to @givfnz2 for his many contributions to the bot!*",
"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.",
"botAbout": "*About the bot*\n\nKowalski 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\nSee the source code: [Click here to go to GitHub](https://github.com/abocn/TelegramBot)",
"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\nSee the source code: [Click here to go to GitHub]({sourceLink})",
"aboutBot": "About the bot",
"unKnown": "Unknown",
"varYes": "Yes",

View file

@ -1,8 +1,8 @@
{
"botWelcome": "*Olá! Eu sou o Kowalski!*\nFui feito com carinho por uns nerds que gostam de programação!\n\n*Antes de usar, você precisa ler a política de privacidade (/privacy) para entender onde seus dados vão ao usar este bot.*\n\nAlém disso, você pode usar /help para ver os comandos do bot!\n\n*Agradecimento especial ao @givfnz2 pelas suas várias contribuições ao bot!*",
"botHelp": "*Oi, eu sou o Kowalski, um bot simples feito do zero em Telegraf e Node.js por uns nerds que gostam de programação.*\n\nClique nos botões abaixo para ver quais comandos você pode usar!\n",
"botWelcome": "*Olá! Eu sou o {botName}!*\nFui feito com carinho por uns nerds que gostam de programação!\n\n*Antes de usar, você precisa ler a política de privacidade (/privacy) para entender onde seus dados vão ao usar este bot.*\n\nAlém disso, você pode usar /help para ver os comandos do bot!\n\n*Agradecimento especial ao @givfnz2 pelas suas várias contribuições ao bot!*",
"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\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.",
"botAbout": "*Sobre o bot*\n\nKowalski foi feito 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\nVeja o código fonte: [Clique aqui para ir ao GitHub](https://github.com/abocn/TelegramBot)",
"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\nVeja o código fonte: [Clique aqui para ir ao GitHub]({sourceLink})",
"aboutBot": "Sobre o bot",
"unKnown": "Desconhecido",
"varYes": "Sim",