From 57154bcb703ea56453f9172c0400aaddf46b9dee Mon Sep 17 00:00:00 2001 From: Lucas Gabriel <90426410+lucmsilva651@users.noreply.github.com> Date: Sun, 2 Jun 2024 00:26:48 +0000 Subject: [PATCH] Markdown formatting + some fixes --- src/commands/.start.js | 11 ----------- src/commands/chatinfo.js | 22 +++++++++++----------- src/commands/furry.js | 14 +++++++------- src/commands/gay.js | 16 ++++++++-------- src/commands/help.js | 25 ++++++++++++++----------- src/commands/start.js | 9 +++++---- src/commands/whois.js | 20 ++++++++++---------- src/main.js | 2 +- 8 files changed, 56 insertions(+), 63 deletions(-) delete mode 100644 src/commands/.start.js diff --git a/src/commands/.start.js b/src/commands/.start.js deleted file mode 100644 index a3c6a98..0000000 --- a/src/commands/.start.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = function(bot, msg) { - const chatId = msg.chat.id; - 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 sent:', error)); - console.log(`INFO: /start executed by ${userName}, ${userId}`) -} \ No newline at end of file diff --git a/src/commands/chatinfo.js b/src/commands/chatinfo.js index eabf24f..c059bc1 100644 --- a/src/commands/chatinfo.js +++ b/src/commands/chatinfo.js @@ -10,27 +10,27 @@ module.exports = function(bot, msg) { let isForumOutput = ""; if (isForum) { - isForumOutput = "This chat is a forum (has topics enabled)"; + isForumOutput = "*This chat is a forum (has topics enabled).*"; } else { - isForumOutput = "This chat is not a forum (doesn't have topics enabled)"; - }; + isForumOutput = "*This chat is not a forum (doesn't have topics enabled).*"; + } if (chatHandle) { - chatHandleOutput = `Chat handle: @${chatHandle}`; + chatHandleOutput = `*Chat handle:* @${chatHandle}`; } else { - chatHandleOutput = `Chat handle: none (private group)`; - }; + chatHandleOutput = `*Chat handle:* none (private group)`; + } // if chatName returns undefined, the chat is not a group or channel if (chatName) { - chatNameOutput = `Chat name: ${chatName}\n${chatHandleOutput}\nChat ID: ${chatId}\n\n${isForumOutput}`; + chatNameOutput = `*Chat name:* ${chatName}\n${chatHandleOutput}\n*Chat ID:* ${chatId}\n\n${isForumOutput}`; } else { - chatNameOutput = `Whoops!\nThis command doesn't work in PM.` - }; + chatNameOutput = "Whoops!\nThis command doesn't work in PM."; + } const message = chatNameOutput; - bot.sendMessage(chatId, message) + bot.sendMessage(chatId, message, { parse_mode: 'Markdown' }) .catch(error => console.error('ERROR: Message cannot be sent:', error)); console.log(`INFO: /chatinfo executed by ${userName}, ${userId}`); -} \ No newline at end of file +} diff --git a/src/commands/furry.js b/src/commands/furry.js index 51a3a9a..65a1160 100644 --- a/src/commands/furry.js +++ b/src/commands/furry.js @@ -6,19 +6,19 @@ module.exports = function(bot, msg) { function getRandomInt(max) { return Math.floor(Math.random() * max); - }; + } const randomValue = getRandomInt(2); if (randomValue === 0) { - isFurry = `You (${userName}) are not a furry.`; + isFurry = `*You (${userName}) are not a furry.*`; } else { - isFurry = `Yes, you (${userName}) are a furry.`; - }; + isFurry = `*Yes, you (${userName}) are a furry.*`; + } const message = `${isFurry}`; - bot.sendMessage(chatId, message) + bot.sendMessage(chatId, message, { parse_mode: 'Markdown' }) .catch(error => console.error('ERROR: Message cannot be sent:', error)); - console.log(`INFO: /furry executed by ${userName}, ${userId}`) -} \ No newline at end of file + console.log(`INFO: /furry executed by ${userName}, ${userId}`); +} diff --git a/src/commands/gay.js b/src/commands/gay.js index 1a90f8a..2456dc4 100644 --- a/src/commands/gay.js +++ b/src/commands/gay.js @@ -1,4 +1,4 @@ -module.exports = function (bot, msg) { +module.exports = function(bot, msg) { const chatId = msg.chat.id; const userName = msg.from.first_name; const userId = msg.from.id; @@ -6,19 +6,19 @@ module.exports = function (bot, msg) { function getRandomInt(max) { return Math.floor(Math.random() * max); - }; + } const randomValue = getRandomInt(2); if (randomValue === 0) { - isGay = `You (${userName}) are not a gay.`; + isGay = `*You (${userName}) are not gay.*`; } else { - isGay = `Yes, you (${userName}) are a gay.`; - }; + isGay = `*Yes, you (${userName}) are gay.*`; + } const message = `${isGay}`; - bot.sendMessage(chatId, message) + bot.sendMessage(chatId, message, { parse_mode: 'Markdown' }) .catch(error => console.error('ERROR: Message cannot be sent:', error)); - console.log(`INFO: /gay executed by ${userName}, ${userId}`) -} \ No newline at end of file + console.log(`INFO: /gay executed by ${userName}, ${userId}`); +} diff --git a/src/commands/help.js b/src/commands/help.js index bca1231..f61f063 100644 --- a/src/commands/help.js +++ b/src/commands/help.js @@ -2,18 +2,21 @@ module.exports = function(bot, msg) { const chatId = msg.chat.id; const userName = msg.from.first_name; const userId = msg.from.id; - const lynxPhoto = 'https://graph.org/file/a77382dab4d62ba626806.jpg' + const lynxFullPhoto = 'https://graph.org/file/a77382dab4d62ba626806.jpg'; - 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 - • /chatinfo: send some information about the group - • /furry: check if you are a furry - • /gay: check if you are a gay\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 ❤️`; + const message = `*Hello! I'm Lynx!*\n\nI'm a simple bot made entirely from scratch in Node.js by Lucas Gabriel (lucmsilva).\n\n` + + `I might be running on a GitHub Codespaces server (see /stats), so please refrain from overusing or spamming the bot!\n\n` + + `*Some commands to test*: + • */start*: start the bot + • */help*: send this message + • */whois*: send some information about yourself + • */chatinfo*: send some information about the group + • */furry*: check if you are a furry + • */gay*: check if you are gay\n\n` + + `*See my source code in:* [GitHub Repository](https://github.com/lucmsilva651/lynx)\n\n` + + `Thanks to all users, testers, contributors, and others. Without you, perhaps this bot wouldn't be possible ❤️`; - bot.sendPhoto(chatId, lynxPhoto, { caption: message }) - .catch(error => console.error('ERROR: Message cannot be send:', error)); + bot.sendPhoto(chatId, lynxFullPhoto, { caption: message, parse_mode: 'Markdown' }) + .catch(error => console.error('ERROR: Message cannot be sent:', error)); console.log(`INFO: /help executed by ${userName}, ${userId}`); } diff --git a/src/commands/start.js b/src/commands/start.js index a3c6a98..da32f80 100644 --- a/src/commands/start.js +++ b/src/commands/start.js @@ -2,10 +2,11 @@ module.exports = function(bot, msg) { const chatId = msg.chat.id; const userName = msg.from.first_name; const userId = msg.from.id; + const lynxProfilePhoto = 'https://graph.org/file/10452df450f13ffb968c5.jpg'; - const message = `Hello! I am Lynx!\nI was made with love by Lucas Gabriel (lucmsilva)!\n\nSee /help for the bot commands!` + 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) + bot.sendPhoto(chatId, lynxProfilePhoto, { caption: message, parse_mode: 'Markdown' } ) .catch(error => console.error('ERROR: Message cannot be sent:', error)); - console.log(`INFO: /start executed by ${userName}, ${userId}`) -} \ No newline at end of file + console.log(`INFO: /start executed by ${userName}, ${userId}`); +} diff --git a/src/commands/whois.js b/src/commands/whois.js index d200bf8..c058e2a 100644 --- a/src/commands/whois.js +++ b/src/commands/whois.js @@ -10,20 +10,20 @@ module.exports = function(bot, msg) { let userPremiumOutput = ""; if (userPremium) { - userPremiumOutput = "You have a Telegram Premium subscription."; + userPremiumOutput = "*You have a Telegram Premium subscription.*"; } else { - userPremiumOutput = "You don't have a Telegram Premium subscription."; - }; + userPremiumOutput = "*You don't have a Telegram Premium subscription.*"; + } if (userHandle) { - haveUsername = `Your username is: @${userHandle}`; + haveUsername = `*Your username is:* @${userHandle}`; } else { - haveUsername = "Your username is: none"; - }; + haveUsername = "*Your username is:* none"; + } - const message = `Your name is: ${userName}\n${haveUsername}\nYour ID is: ${userId}\nYou are a bot: ${isBot}\nYour language: ${userLang}\n\n${userPremiumOutput}`; + const message = `*Your name is:* ${userName}\n${haveUsername}\n*Your ID is:* ${userId}\n*You are a bot:* ${isBot}\n*Your language:* ${userLang}\n\n${userPremiumOutput}`; - bot.sendMessage(chatId, message) + bot.sendMessage(chatId, message, { parse_mode: 'Markdown' }) .catch(error => console.error('ERROR: Message cannot be sent:', error)); - console.log(`INFO: /whois executed by ${userName}, ${userId}`) -} \ No newline at end of file + console.log(`INFO: /whois executed by ${userName}, ${userId}`); +} diff --git a/src/main.js b/src/main.js index 97f7547..bbbc710 100644 --- a/src/main.js +++ b/src/main.js @@ -26,4 +26,4 @@ bot.on('polling_error', (error) => { }); const date = Date(); -console.log(`INFO: Lynx started at ${date}\n`) \ No newline at end of file +console.log(`INFO: Lynx started at: \n• ${date}\n`) \ No newline at end of file