2024-05-25 12:37:34 -03:00
|
|
|
module.exports = function(bot, msg) {
|
|
|
|
const chatId = msg.chat.id;
|
2024-05-25 12:56:54 -03:00
|
|
|
const chatName = msg.chat.title;
|
2024-05-25 12:37:34 -03:00
|
|
|
const chatHandle = msg.chat.username;
|
|
|
|
const isForum = msg.chat.is_forum;
|
2024-05-25 12:56:54 -03:00
|
|
|
let chatNameOutput = "";
|
2024-05-25 12:37:34 -03:00
|
|
|
let chatHandleOutput = "";
|
2024-05-25 12:56:54 -03:00
|
|
|
let isForumOutput = "";
|
2024-05-25 12:37:34 -03:00
|
|
|
|
|
|
|
if (isForum) {
|
2024-06-02 00:26:48 +00:00
|
|
|
isForumOutput = "*This chat is a forum (has topics enabled).*";
|
2024-05-25 12:37:34 -03:00
|
|
|
} else {
|
2024-06-02 00:26:48 +00:00
|
|
|
isForumOutput = "*This chat is not a forum (doesn't have topics enabled).*";
|
|
|
|
}
|
2024-05-25 12:37:34 -03:00
|
|
|
|
|
|
|
if (chatHandle) {
|
2024-06-02 15:18:27 +00:00
|
|
|
chatHandleOutput = `*Chat handle:* \`@${chatHandle}`;
|
2024-05-25 12:37:34 -03:00
|
|
|
} else {
|
2024-06-02 15:18:27 +00:00
|
|
|
chatHandleOutput = `*Chat handle:* \`none (private group)\``;
|
2024-06-02 00:26:48 +00:00
|
|
|
}
|
2024-05-25 12:59:05 -03:00
|
|
|
|
|
|
|
// if chatName returns undefined, the chat is not a group or channel
|
2024-05-25 12:56:54 -03:00
|
|
|
if (chatName) {
|
2024-06-02 15:18:27 +00:00
|
|
|
chatNameOutput = `*Chat name:* \`${chatName}\`\n${chatHandleOutput}\n*Chat ID:* \`${chatId}\`\n\n${isForumOutput}`;
|
2024-05-25 12:56:54 -03:00
|
|
|
} else {
|
2024-06-02 00:26:48 +00:00
|
|
|
chatNameOutput = "Whoops!\nThis command doesn't work in PM.";
|
|
|
|
}
|
2024-05-25 12:56:54 -03:00
|
|
|
|
|
|
|
const message = chatNameOutput;
|
2024-05-25 12:37:34 -03:00
|
|
|
|
2024-06-02 00:26:48 +00:00
|
|
|
bot.sendMessage(chatId, message, { parse_mode: 'Markdown' })
|
2024-06-02 13:27:01 +00:00
|
|
|
.catch(error => console.error('WARN: Message cannot be sent: ', error));
|
2024-06-02 00:26:48 +00:00
|
|
|
}
|