mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-09-02 15:15:20 +00:00
checks if group already has link before exporting one
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
const bot = require('../../bot');
|
const bot = require('../../bot');
|
||||||
const { replyOptions } = require('../../bot/options');
|
const { replyOptions } = require('../../bot/options');
|
||||||
|
|
||||||
const { addGroup } = require('../../stores/group');
|
const { addGroup, managesGroup } = require('../../stores/group');
|
||||||
const { masterID } = require('../../config.json');
|
const { masterID } = require('../../config.json');
|
||||||
|
|
||||||
const addedToGroupHandler = async (ctx, next) => {
|
const addedToGroupHandler = async (ctx, next) => {
|
||||||
@@ -13,9 +13,11 @@ const addedToGroupHandler = async (ctx, next) => {
|
|||||||
const wasAdded = msg.new_chat_members.some(user =>
|
const wasAdded = msg.new_chat_members.some(user =>
|
||||||
user.username === ctx.me);
|
user.username === ctx.me);
|
||||||
if (wasAdded && ctx.from.id === masterID) {
|
if (wasAdded && ctx.from.id === masterID) {
|
||||||
|
if (!await managesGroup(ctx.chat)) {
|
||||||
const link = await bot.telegram.exportChatInviteLink(ctx.chat.id);
|
const link = await bot.telegram.exportChatInviteLink(ctx.chat.id);
|
||||||
ctx.chat.link = link ? link : '';
|
ctx.chat.link = link ? link : '';
|
||||||
addGroup(ctx.chat);
|
await addGroup(ctx.chat);
|
||||||
|
}
|
||||||
ctx.reply('🛠 <b>Ok, I\'ll help you manage this group from now.</b>',
|
ctx.reply('🛠 <b>Ok, I\'ll help you manage this group from now.</b>',
|
||||||
replyOptions);
|
replyOptions);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user