2024-07-25 23:57:38 -03:00
|
|
|
const { getStrings } = require('../plugins/checklang.js');
|
2024-07-28 13:31:04 -03:00
|
|
|
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
|
|
|
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
2024-07-24 22:39:27 -03:00
|
|
|
|
|
|
|
async function getUserInfo(ctx) {
|
2024-07-25 23:40:22 -03:00
|
|
|
const Strings = getStrings(ctx.from.language_code);
|
2024-07-24 22:39:27 -03:00
|
|
|
|
2024-08-30 21:12:38 -03:00
|
|
|
userInfo = Strings.userInfo
|
2024-09-06 21:56:19 -03:00
|
|
|
.replace('{userName}', `${ctx.from.first_name} ${ctx.from.last_name}` || Strings.unKnown)
|
2024-08-30 21:12:38 -03:00
|
|
|
.replace('{userId}', ctx.from.id || Strings.unKnown)
|
|
|
|
.replace('{userHandle}', ctx.from.username ? `@${ctx.from.username}` : Strings.varNone)
|
|
|
|
.replace('{userPremium}', ctx.from.is_premium ? Strings.varYes : Strings.varNo)
|
|
|
|
.replace('{userLang}', ctx.from.language_code || Strings.unKnown);
|
2024-07-24 22:39:27 -03:00
|
|
|
|
2024-08-30 21:12:38 -03:00
|
|
|
return userInfo;
|
2024-07-24 22:39:27 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
async function getChatInfo(ctx) {
|
2024-07-25 23:40:22 -03:00
|
|
|
const Strings = getStrings(ctx.from.language_code);
|
2024-07-24 22:39:27 -03:00
|
|
|
if (ctx.chat.type === 'group' || ctx.chat.type === 'supergroup') {
|
2024-08-30 21:12:38 -03:00
|
|
|
chatInfo = Strings.chatInfo
|
|
|
|
.replace('{chatId}', ctx.chat.id || Strings.unKnown)
|
|
|
|
.replace('{chatName}', ctx.chat.title || Strings.unKnown)
|
|
|
|
.replace('{chatHandle}', ctx.chat.username ? `@${ctx.chat.username}` : Strings.varNone)
|
|
|
|
.replace('{chatMembersCount}', await ctx.getChatMembersCount(ctx.chat.id || Strings.unKnown))
|
|
|
|
.replace('{chatType}', ctx.chat.type || Strings.unKnown)
|
|
|
|
.replace('{isForum}', ctx.chat.is_forum ? Strings.varYes : Strings.varNo);
|
2024-07-24 22:39:27 -03:00
|
|
|
|
2024-08-30 21:12:38 -03:00
|
|
|
return chatInfo;
|
2024-07-24 22:39:27 -03:00
|
|
|
} else {
|
2024-07-28 11:48:30 -03:00
|
|
|
return ctx.reply(
|
|
|
|
Strings.groupOnly, {
|
|
|
|
parse_mode: 'Markdown',
|
|
|
|
reply_to_message_id: ctx.message.message_id
|
|
|
|
});
|
2024-07-24 22:39:27 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = (bot) => {
|
2024-07-28 13:31:04 -03:00
|
|
|
bot.command('chatinfo', spamwatchMiddleware, async (ctx) => {
|
2024-07-24 22:39:27 -03:00
|
|
|
const chatInfo = await getChatInfo(ctx);
|
|
|
|
ctx.reply(
|
|
|
|
chatInfo, {
|
2024-07-25 03:55:05 +00:00
|
|
|
parse_mode: 'Markdown',
|
|
|
|
reply_to_message_id: ctx.message.message_id
|
2024-07-24 22:39:27 -03:00
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2024-07-28 13:31:04 -03:00
|
|
|
bot.command('userinfo', spamwatchMiddleware, async (ctx) => {
|
2024-07-24 22:39:27 -03:00
|
|
|
const userInfo = await getUserInfo(ctx);
|
|
|
|
ctx.reply(
|
|
|
|
userInfo, {
|
2024-07-25 03:55:05 +00:00
|
|
|
parse_mode: 'Markdown',
|
|
|
|
reply_to_message_id: ctx.message.message_id,
|
2024-07-24 22:39:27 -03:00
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
};
|