mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 21:00:03 +00:00
Markdown formatting + some fixes
This commit is contained in:
parent
1ec0af7cdb
commit
57154bcb70
@ -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}`)
|
|
||||||
}
|
|
@ -10,27 +10,27 @@ module.exports = function(bot, msg) {
|
|||||||
let isForumOutput = "";
|
let isForumOutput = "";
|
||||||
|
|
||||||
if (isForum) {
|
if (isForum) {
|
||||||
isForumOutput = "This chat is a forum (has topics enabled)";
|
isForumOutput = "*This chat is a forum (has topics enabled).*";
|
||||||
} else {
|
} 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) {
|
if (chatHandle) {
|
||||||
chatHandleOutput = `Chat handle: @${chatHandle}`;
|
chatHandleOutput = `*Chat handle:* @${chatHandle}`;
|
||||||
} else {
|
} 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 returns undefined, the chat is not a group or channel
|
||||||
if (chatName) {
|
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 {
|
} else {
|
||||||
chatNameOutput = `Whoops!\nThis command doesn't work in PM.`
|
chatNameOutput = "Whoops!\nThis command doesn't work in PM.";
|
||||||
};
|
}
|
||||||
|
|
||||||
const message = chatNameOutput;
|
const message = chatNameOutput;
|
||||||
|
|
||||||
bot.sendMessage(chatId, message)
|
bot.sendMessage(chatId, message, { parse_mode: 'Markdown' })
|
||||||
.catch(error => console.error('ERROR: Message cannot be sent:', error));
|
.catch(error => console.error('ERROR: Message cannot be sent:', error));
|
||||||
console.log(`INFO: /chatinfo executed by ${userName}, ${userId}`);
|
console.log(`INFO: /chatinfo executed by ${userName}, ${userId}`);
|
||||||
}
|
}
|
@ -6,19 +6,19 @@ module.exports = function(bot, msg) {
|
|||||||
|
|
||||||
function getRandomInt(max) {
|
function getRandomInt(max) {
|
||||||
return Math.floor(Math.random() * max);
|
return Math.floor(Math.random() * max);
|
||||||
};
|
}
|
||||||
|
|
||||||
const randomValue = getRandomInt(2);
|
const randomValue = getRandomInt(2);
|
||||||
|
|
||||||
if (randomValue === 0) {
|
if (randomValue === 0) {
|
||||||
isFurry = `You (${userName}) are not a furry.`;
|
isFurry = `*You (${userName}) are not a furry.*`;
|
||||||
} else {
|
} else {
|
||||||
isFurry = `Yes, you (${userName}) are a furry.`;
|
isFurry = `*Yes, you (${userName}) are a furry.*`;
|
||||||
};
|
}
|
||||||
|
|
||||||
const message = `${isFurry}`;
|
const message = `${isFurry}`;
|
||||||
|
|
||||||
bot.sendMessage(chatId, message)
|
bot.sendMessage(chatId, message, { parse_mode: 'Markdown' })
|
||||||
.catch(error => console.error('ERROR: Message cannot be sent:', error));
|
.catch(error => console.error('ERROR: Message cannot be sent:', error));
|
||||||
console.log(`INFO: /furry executed by ${userName}, ${userId}`)
|
console.log(`INFO: /furry executed by ${userName}, ${userId}`);
|
||||||
}
|
}
|
@ -6,19 +6,19 @@ module.exports = function (bot, msg) {
|
|||||||
|
|
||||||
function getRandomInt(max) {
|
function getRandomInt(max) {
|
||||||
return Math.floor(Math.random() * max);
|
return Math.floor(Math.random() * max);
|
||||||
};
|
}
|
||||||
|
|
||||||
const randomValue = getRandomInt(2);
|
const randomValue = getRandomInt(2);
|
||||||
|
|
||||||
if (randomValue === 0) {
|
if (randomValue === 0) {
|
||||||
isGay = `You (${userName}) are not a gay.`;
|
isGay = `*You (${userName}) are not gay.*`;
|
||||||
} else {
|
} else {
|
||||||
isGay = `Yes, you (${userName}) are a gay.`;
|
isGay = `*Yes, you (${userName}) are gay.*`;
|
||||||
};
|
}
|
||||||
|
|
||||||
const message = `${isGay}`;
|
const message = `${isGay}`;
|
||||||
|
|
||||||
bot.sendMessage(chatId, message)
|
bot.sendMessage(chatId, message, { parse_mode: 'Markdown' })
|
||||||
.catch(error => console.error('ERROR: Message cannot be sent:', error));
|
.catch(error => console.error('ERROR: Message cannot be sent:', error));
|
||||||
console.log(`INFO: /gay executed by ${userName}, ${userId}`)
|
console.log(`INFO: /gay executed by ${userName}, ${userId}`);
|
||||||
}
|
}
|
@ -2,18 +2,21 @@ module.exports = function(bot, msg) {
|
|||||||
const chatId = msg.chat.id;
|
const chatId = msg.chat.id;
|
||||||
const userName = msg.from.first_name;
|
const userName = msg.from.first_name;
|
||||||
const userId = msg.from.id;
|
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:
|
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` +
|
||||||
• /start: start the bot
|
`I might be running on a GitHub Codespaces server (see /stats), so please refrain from overusing or spamming the bot!\n\n` +
|
||||||
• /help: send this message
|
`*Some commands to test*:
|
||||||
• /whois: send some information about yourself
|
• */start*: start the bot
|
||||||
• /chatinfo: send some information about the group
|
• */help*: send this message
|
||||||
• /furry: check if you are a furry
|
• */whois*: send some information about yourself
|
||||||
• /gay: check if you are a gay\n\nSee my source code in:
|
• */chatinfo*: send some information about the group
|
||||||
• https://github.com/lucmsilva651/lynx.\n\nThanks to all users, testers, contributors, and others. Without you, perhaps this bot wouldn't be possible ❤️`;
|
• */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 })
|
bot.sendPhoto(chatId, lynxFullPhoto, { caption: message, parse_mode: 'Markdown' })
|
||||||
.catch(error => console.error('ERROR: Message cannot be send:', error));
|
.catch(error => console.error('ERROR: Message cannot be sent:', error));
|
||||||
console.log(`INFO: /help executed by ${userName}, ${userId}`);
|
console.log(`INFO: /help executed by ${userName}, ${userId}`);
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,11 @@ module.exports = function(bot, msg) {
|
|||||||
const chatId = msg.chat.id;
|
const chatId = msg.chat.id;
|
||||||
const userName = msg.from.first_name;
|
const userName = msg.from.first_name;
|
||||||
const userId = msg.from.id;
|
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));
|
.catch(error => console.error('ERROR: Message cannot be sent:', error));
|
||||||
console.log(`INFO: /start executed by ${userName}, ${userId}`)
|
console.log(`INFO: /start executed by ${userName}, ${userId}`);
|
||||||
}
|
}
|
@ -10,20 +10,20 @@ module.exports = function(bot, msg) {
|
|||||||
let userPremiumOutput = "";
|
let userPremiumOutput = "";
|
||||||
|
|
||||||
if (userPremium) {
|
if (userPremium) {
|
||||||
userPremiumOutput = "You have a Telegram Premium subscription.";
|
userPremiumOutput = "*You have a Telegram Premium subscription.*";
|
||||||
} else {
|
} else {
|
||||||
userPremiumOutput = "You don't have a Telegram Premium subscription.";
|
userPremiumOutput = "*You don't have a Telegram Premium subscription.*";
|
||||||
};
|
}
|
||||||
|
|
||||||
if (userHandle) {
|
if (userHandle) {
|
||||||
haveUsername = `Your username is: @${userHandle}`;
|
haveUsername = `*Your username is:* @${userHandle}`;
|
||||||
} else {
|
} 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));
|
.catch(error => console.error('ERROR: Message cannot be sent:', error));
|
||||||
console.log(`INFO: /whois executed by ${userName}, ${userId}`)
|
console.log(`INFO: /whois executed by ${userName}, ${userId}`);
|
||||||
}
|
}
|
@ -26,4 +26,4 @@ bot.on('polling_error', (error) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const date = Date();
|
const date = Date();
|
||||||
console.log(`INFO: Lynx started at ${date}\n`)
|
console.log(`INFO: Lynx started at: \n• ${date}\n`)
|
Loading…
x
Reference in New Issue
Block a user