diff --git a/bot.js b/bot.js index e1f4d22..c9d2a51 100644 --- a/bot.js +++ b/bot.js @@ -29,14 +29,16 @@ class TelegramHistoryBot { this.init(); } - isAdmin (ctx, userId = ctx.from.id) { + async isAdmin(ctx, userId = ctx.from.id) { try { - const member = ctx.getChatMember(userId) + const member = await ctx.getChatMember(userId) return ['creator', 'administrator'].includes(member.status) - } catch { + } catch (error) { + logger.error('Ошибка проверки статуса пользователя:', error) return false } } + async init() { try { await this.loadHistory(); @@ -70,6 +72,10 @@ class TelegramHistoryBot { setupHandlers() { this.bot.command('summy', async (ctx) => { + if (!(await this.isAdmin(ctx))) { + await ctx.deleteMessage() + return + } const message = ctx.message.text || ''; const args = message.replace(/^\/summy(@\w+)?\s*/, ''); // удаляет /summy и возможный @botname const trimmed = args.trim(); // удаляет лишние пробелы по краям, если нужно