From 8d34495256bb88b7b56525cb7db515655d1a30c4 Mon Sep 17 00:00:00 2001 From: Lucas Gabriel <90426410+lucmsilva651@users.noreply.github.com> Date: Fri, 24 May 2024 20:08:22 -0300 Subject: [PATCH] Push some updates on start + whois added --- src/commands/start.js | 10 ++++++++-- src/commands/whois.js | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/commands/whois.js diff --git a/src/commands/start.js b/src/commands/start.js index 9d3e449..bd48a28 100644 --- a/src/commands/start.js +++ b/src/commands/start.js @@ -1,6 +1,12 @@ // start command handler module.exports = function(bot, msg) { const chatId = msg.chat.id; - bot.sendMessage(chatId, "Welcome to Lynx!\n\nI was made with love by Lucas Gabriel (lucmsilva)!\n\nCheck out my source code:\nhttps://github.com/lucmsilva651/lynx") - console.log("INFO: /start executed.") + const userName = msg.from.first_name; + const userId = msg.from.id; + + const message = `Hello! I am Lynx!\nI was made with love by Lucas Gabriel (lucmsilva)!\n\nSee /help for the bot commands!` + + bot.sendMessage(chatId, message) + .catch(error => console.error('ERROR: Message cannot be send:', error)); + console.log(`INFO: /start executed by ${userName}, ${userId}`) } \ No newline at end of file diff --git a/src/commands/whois.js b/src/commands/whois.js new file mode 100644 index 0000000..ebe0d84 --- /dev/null +++ b/src/commands/whois.js @@ -0,0 +1,19 @@ +module.exports = function(bot, msg) { + const chatId = msg.chat.id; + const userName = msg.from.first_name; + const userId = msg.from.id; + const userHandle = msg.from.username; + const isBot = msg.from.is_bot; + const userPremium = msg.from.is_premium; + const userPremiumOutput = ""; + + if (userPremium == "true") { + const userPremiumOutput = "\n\nYou have a Telegram Premium subscription."; + } + + const message = `Your name is: ${userName}\nYour username is: ${userHandle}\nYour ID is: ${userId}\nYou are a bot: ${isBot}` + userPremiumOutput; + + bot.sendMessage(chatId, message) + .catch(error => console.error('ERROR: Message cannot be send:', error)); + console.log(`INFO: /whois executed by ${userName}, ${userId}`) +} \ No newline at end of file