mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-11 13:19:57 +00:00
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
module.exports = function(bot, msg) {
|
|
const chatId = msg.chat.id;
|
|
const chatName = msg.chat.title;
|
|
const chatHandle = msg.chat.username;
|
|
const isForum = msg.chat.is_forum;
|
|
let chatNameOutput = "";
|
|
let chatHandleOutput = "";
|
|
let isForumOutput = "";
|
|
|
|
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)\``;
|
|
}
|
|
|
|
// if chatName returns undefined, the chat is not a group or channel
|
|
if (chatName) {
|
|
chatNameOutput = `*Chat name:* \`${chatName}\`\n${chatHandleOutput}\n*Chat ID:* \`${chatId}\`\n\n${isForumOutput}`;
|
|
} else {
|
|
chatNameOutput = "Whoops!\nThis command doesn't work in PM.";
|
|
}
|
|
|
|
const message = chatNameOutput;
|
|
|
|
bot.sendMessage(chatId, message, { parse_mode: 'Markdown' })
|
|
.catch(error => console.error('WARN: Message cannot be sent: ', error));
|
|
}
|