mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 21:00:03 +00:00
Added chatinfo + typo fixes + whois update
This commit is contained in:
parent
318dce8e0b
commit
6d1a1ae745
28
src/commands/chatinfo.js
Normal file
28
src/commands/chatinfo.js
Normal file
@ -0,0 +1,28 @@
|
||||
module.exports = function(bot, msg) {
|
||||
const chatId = msg.chat.id;
|
||||
const chatName = msg.chat.title;
|
||||
const userName = msg.from.first_name;
|
||||
const userId = msg.from.id;
|
||||
const chatHandle = msg.chat.username;
|
||||
const isForum = msg.chat.is_forum;
|
||||
let isForumOutput = "";
|
||||
let chatHandleOutput = "";
|
||||
|
||||
if (isForum) {
|
||||
isForumOutput = "This chat is a forum (has topics enabled)";
|
||||
} else {
|
||||
isForumOutput = "This chat is not a forum (doesn't have topics enabled)";
|
||||
}
|
||||
|
||||
if (chatHandle) {
|
||||
chatHandleOutput = `Chat handle: @${chatHandle}`;
|
||||
} else {
|
||||
chatHandleOutput = `Chat handle: none (private group)`;
|
||||
}
|
||||
|
||||
const message = `Chat name: ${chatName}\n${chatHandleOutput}\nChat ID: ${chatId}\n\n${isForumOutput}`;
|
||||
|
||||
bot.sendMessage(chatId, message)
|
||||
.catch(error => console.error('ERROR: Message cannot be sent:', error));
|
||||
console.log(`INFO: /chatinfo executed by ${userName}, ${userId}`);
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
// start command handler
|
||||
module.exports = function(bot, msg) {
|
||||
const chatId = msg.chat.id;
|
||||
const userName = msg.from.first_name;
|
||||
@ -7,6 +6,6 @@ module.exports = function(bot, msg) {
|
||||
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));
|
||||
.catch(error => console.error('ERROR: Message cannot be sent:', error));
|
||||
console.log(`INFO: /start executed by ${userName}, ${userId}`)
|
||||
}
|
@ -5,6 +5,7 @@ module.exports = function(bot, msg) {
|
||||
const userHandle = msg.from.username;
|
||||
const isBot = msg.from.is_bot;
|
||||
const userPremium = msg.from.is_premium;
|
||||
const userLang = msg.from.language_code;
|
||||
let userPremiumOutput = "";
|
||||
|
||||
if (userPremium) {
|
||||
@ -13,9 +14,9 @@ module.exports = function(bot, msg) {
|
||||
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}\n\n${userPremiumOutput}`;
|
||||
const message = `Your name is: ${userName}\nYour username is: @${userHandle}\nYour ID is: ${userId}\nYou are a bot: ${isBot}\nYour language: ${userLang}\n\n${userPremiumOutput}`;
|
||||
|
||||
bot.sendMessage(chatId, message)
|
||||
.catch(error => console.error('ERROR: Message cannot be send:', error));
|
||||
.catch(error => console.error('ERROR: Message cannot be sent:', error));
|
||||
console.log(`INFO: /whois executed by ${userName}, ${userId}`)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user