PM check in chatinfo

This commit is contained in:
Lucas Gabriel 2024-05-25 12:56:54 -03:00
parent 14986fc99b
commit e0380eeebf
No known key found for this signature in database
GPG Key ID: D9B075FC6DC93985

View File

@ -1,12 +1,13 @@
module.exports = function(bot, msg) { module.exports = function(bot, msg) {
const chatId = msg.chat.id; const chatId = msg.chat.id;
const chatName = msg.chat.title;
const userName = msg.from.first_name; const userName = msg.from.first_name;
const userId = msg.from.id; const userId = msg.from.id;
const chatName = msg.chat.title;
const chatHandle = msg.chat.username; const chatHandle = msg.chat.username;
const isForum = msg.chat.is_forum; const isForum = msg.chat.is_forum;
let isForumOutput = ""; let chatNameOutput = "";
let chatHandleOutput = ""; let chatHandleOutput = "";
let isForumOutput = "";
if (isForum) { if (isForum) {
isForumOutput = "This chat is a forum (has topics enabled)"; isForumOutput = "This chat is a forum (has topics enabled)";
@ -20,7 +21,13 @@ module.exports = function(bot, msg) {
chatHandleOutput = `Chat handle: none (private group)`; chatHandleOutput = `Chat handle: none (private group)`;
} }
const message = `Chat name: ${chatName}\n${chatHandleOutput}\nChat ID: ${chatId}\n\n${isForumOutput}`; if (chatName) {
chatNameOutput = `Chat name: ${chatName}\n${chatHandleOutput}\nChat ID: ${chatId}\n\n${isForumOutput}`;
} else {
chatNameOutput = `Whoops!\nThis command doesn't work in PM.`
}
const message = chatNameOutput;
bot.sendMessage(chatId, message) bot.sendMessage(chatId, message)
.catch(error => console.error('ERROR: Message cannot be sent:', error)); .catch(error => console.error('ERROR: Message cannot be sent:', error));