Fixed whois + added help

This commit is contained in:
Lucas Gabriel 2024-05-24 20:57:44 -03:00
parent 8d34495256
commit 977291d639
No known key found for this signature in database
GPG Key ID: D9B075FC6DC93985
2 changed files with 23 additions and 6 deletions

15
src/commands/help.js Normal file
View File

@ -0,0 +1,15 @@
module.exports = function(bot, msg) {
const chatId = msg.chat.id;
const userName = msg.from.first_name;
const userId = msg.from.id;
const message = `Hi! I am Lynx!\nI am a simple bot made entirely from scratch in Node.js by Lucas Gabriel (lucmsilva).\n\nSome commands to test:
- /start: start the bot
- /help: send this message
- /whois: send some information about yourself\n\nSee my source code in:
https://github.com/lucmsilva651/lynx.\n\nThanks to all users, testers, contributors, and others. Without you, perhaps this bot wouldn't be possible.`;
bot.sendMessage(chatId, message)
.catch(error => console.error('ERROR: Message cannot be send:', error));
console.log(`INFO: /help executed by ${userName}, ${userId}`);
}

View File

@ -5,13 +5,15 @@ module.exports = function(bot, msg) {
const userHandle = msg.from.username;
const isBot = msg.from.is_bot;
const userPremium = msg.from.is_premium;
const userPremiumOutput = "";
let userPremiumOutput = "";
if (userPremium == "true") {
const userPremiumOutput = "\n\nYou have a Telegram Premium subscription.";
if (userPremium) {
userPremiumOutput = "You have a Telegram Premium subscription.";
} else {
userPremiumOutput = "You don't 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;
const message = `Your name is: ${userName}\nYour username is: ${userHandle}\nYour ID is: ${userId}\nYou are a bot: ${isBot}\n\n${userPremiumOutput}`;
bot.sendMessage(chatId, message)
.catch(error => console.error('ERROR: Message cannot be send:', error));