From 7070a0e51fbcb7cbcd7a0838af3359aac35f3e69 Mon Sep 17 00:00:00 2001 From: lucmsilva651 Date: Sun, 8 Sep 2024 11:27:19 -0300 Subject: [PATCH 1/3] Updated README.md --- README.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1e9810a..1ce9de7 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,15 @@ Lynx is a a simple Telegram bot made in Node.js. - Node.js 20 LTS (or above) - Python 3 (or above, for use with SpamWatch API) - Python dependencies: use ``pip install -r requirements.txt`` - - Node.js dependencies: use ``npm install`` + - Node.js dependencies: use ``npm install .`` ## Run it yourself, develop or contribute with Lynx -First, clone the repo and init the submodules with +First, clone the repo with Git: ``` git clone https://github.com/lucmsilva651/lynx +``` +And now, init the submodules with these commands (this is very important): +``` cd lynx git submodule update --init --recursive ``` @@ -20,17 +23,21 @@ Next, inside the repository directory, go to props folder and create a config.js ``` { "botToken": "0000000000:AAAaaAAaaaaAaAaaAAAaaaAaaaaAAAAAaaa", - "admins": [0000000000, 1111111111, 2222222222] + "admins": [0000000000, 1111111111, 2222222222], + "lastKey": "0000a000a0000aaa0a00a0aaa0a000000", + "lastSecret": "0000a000a0a0000aa0000aa00000000a" } ``` - **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. +- **lastKey**: Last.fm API key, for use on lastfm.js functions, like see who is listening to what song. +- **lastSecret**: Last.fm API secret (optional), which has the "same" purpose as the API key above. After editing the file, save all changes and run the bot with ``npm start``. -- To deal with dependencies, just run ``npm install`` or ``npm i`` at any moment to install any of them. +- To deal with dependencies, just run ``npm install .`` or ``npm i .`` at any moment to install any of them. ## Note - Take care of your ``config.json`` 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! ## About/License -MIT - 2024 Lucas Gabriel (lucmsilva). +BSD-3-Clause - 2024 Lucas Gabriel (lucmsilva). \ No newline at end of file From a10ef8980e476d0ab1a5ba05e5ababa332f64768 Mon Sep 17 00:00:00 2001 From: lucmsilva651 Date: Sun, 8 Sep 2024 11:59:11 -0300 Subject: [PATCH 2/3] Put GSMArena page from device onto message (based on #9) --- commands/gsmarena.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/commands/gsmarena.js b/commands/gsmarena.js index 2b751bb..28aa475 100644 --- a/commands/gsmarena.js +++ b/commands/gsmarena.js @@ -110,9 +110,11 @@ function formatPhone(phone) { .map(([label, key]) => `${label}: ${formattedPhone[key]}`) .join("\n\n"); + + const deviceUrl = `GSMArena page: ${formattedPhone.url}`; const deviceImage = phone.picture ? `Device Image: ${phone.picture}` : ''; - return `${formattedPhone.name}\n\n${attributes}\n\n${deviceImage}`; + return `\n\nName: ${formattedPhone.name}\n\n${attributes}\n\n${deviceImage}\n\n${deviceUrl}`; } async function fetchHtml(url) { @@ -230,7 +232,7 @@ module.exports = (bot) => { if (phoneDetails.name) { const message = formatPhone(phoneDetails); - ctx.editMessageText(`${userName}, there are the details of your device: ` + message, { parse_mode: 'HTML', disable_web_page_preview: false }); + ctx.editMessageText(`${userName}, there are the details of your device:` + message, { parse_mode: 'HTML', disable_web_page_preview: false }); } else { ctx.reply("Error fetching phone details.", { reply_with_message_id: ctx.message.message_id }); } From 51ffe0f94b865e54e812dd4a2494ba645f4286d2 Mon Sep 17 00:00:00 2001 From: GiovaniFZ Date: Sun, 8 Sep 2024 14:00:48 -0300 Subject: [PATCH 3/3] fix: Let last name empty if username doesn't have one --- commands/info.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/commands/info.js b/commands/info.js index 1d57198..fc320ca 100644 --- a/commands/info.js +++ b/commands/info.js @@ -4,9 +4,13 @@ const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(is async function getUserInfo(ctx) { const Strings = getStrings(ctx.from.language_code); + let lastName = ctx.from.last_name; + if (lastName === undefined) { + lastName = " "; + } userInfo = Strings.userInfo - .replace('{userName}', `${ctx.from.first_name} ${ctx.from.last_name}` || Strings.unKnown) + .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)