Reformulation of bot structure
This commit is contained in:
parent
4b9ed6d2c0
commit
2f65126319
15 changed files with 2 additions and 2 deletions
28
commands/whois.js
Normal file
28
commands/whois.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
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 userLang = msg.from.language_code;
|
||||
let haveUsername = "";
|
||||
let userPremiumOutput = "";
|
||||
|
||||
if (userPremium) {
|
||||
userPremiumOutput = "*You have a Telegram Premium subscription.*";
|
||||
} else {
|
||||
userPremiumOutput = "*You don't have a Telegram Premium subscription.*";
|
||||
}
|
||||
|
||||
if (userHandle) {
|
||||
haveUsername = `*Your username is:* @${userHandle}`;
|
||||
} else {
|
||||
haveUsername = "*Your username is:* none";
|
||||
}
|
||||
|
||||
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, { parse_mode: 'Markdown' })
|
||||
.catch(error => console.error('WARN: Message cannot be sent: ', error));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue