Added chatinfo + typo fixes + whois update
This commit is contained in:
parent
318dce8e0b
commit
6d1a1ae745
3 changed files with 32 additions and 4 deletions
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}`);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue