diff --git a/handlers/middlewares/addedToGroup.js b/handlers/middlewares/addedToGroup.js index d1f03f1..5db0f6f 100644 --- a/handlers/middlewares/addedToGroup.js +++ b/handlers/middlewares/addedToGroup.js @@ -4,7 +4,7 @@ const bot = require('../../bot'); const { replyOptions } = require('../../bot/options'); -const { addGroup } = require('../../stores/group'); +const { addGroup, managesGroup } = require('../../stores/group'); const { masterID } = require('../../config.json'); const addedToGroupHandler = async (ctx, next) => { @@ -13,9 +13,11 @@ const addedToGroupHandler = async (ctx, next) => { const wasAdded = msg.new_chat_members.some(user => user.username === ctx.me); if (wasAdded && ctx.from.id === masterID) { - const link = await bot.telegram.exportChatInviteLink(ctx.chat.id); - ctx.chat.link = link ? link : ''; - addGroup(ctx.chat); + if (!await managesGroup(ctx.chat)) { + const link = await bot.telegram.exportChatInviteLink(ctx.chat.id); + ctx.chat.link = link ? link : ''; + await addGroup(ctx.chat); + } ctx.reply('🛠 Ok, I\'ll help you manage this group from now.', replyOptions); }