This commit is contained in:
yasirarism 2023-06-14 14:53:50 +00:00 committed by GitHub
parent a587b365a8
commit 3f84bb7b1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -60,6 +60,10 @@ class Database:
async def delete_user(self, user_id):
await self.col.delete_many({"id": int(user_id)})
async def is_chat_exist(self, id):
user = await self.grp.find_one({"id": int(id)})
return bool(user)
async def get_banned(self):
users = self.col.find({"ban_status.is_banned": True})
chats = self.grp.find({"chat_status.is_disabled": True})

View file

@ -17,8 +17,7 @@ async def ban_reply(self: Client, ctx: Message):
@app.on_message(filters.group & filters.incoming, group=3)
@use_chat_lang()
async def grp_bd(self: Client, ctx: Message, strings):
chck = await db.get_chat(ctx.chat.id)
if not chck:
if not await db.is_chat_exist(ctx.chat.id):
total = await self.get_chat_members_count(ctx.chat.id)
r_j = ctx.from_user.mention if ctx.from_user else "Anonymous"
await self.send_message(
@ -26,6 +25,7 @@ async def grp_bd(self: Client, ctx: Message, strings):
strings("log_bot_added", context="grup_tools").format(ttl=ctx.chat.title, cid=ctx.chat.id, tot=total, r_j=r_j),
)
await db.add_chat(ctx.chat.id, ctx.chat.title)
chck = await db.get_chat(ctx.chat.id)
if chck['is_disabled']:
buttons = [[InlineKeyboardButton("Support", url=f"https://t.me/{SUPPORT_CHAT}")]]
reply_markup = InlineKeyboardMarkup(buttons)