From 3f84bb7b1b65bc14b7d0b57bd08f6c657b612435 Mon Sep 17 00:00:00 2001 From: yasirarism <55983182+yasirarism@users.noreply.github.com> Date: Wed, 14 Jun 2023 14:53:50 +0000 Subject: [PATCH] Fixx --- database/users_chats_db.py | 4 ++++ misskaty/plugins/ban_user_or_chat.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/database/users_chats_db.py b/database/users_chats_db.py index 8f686841..08a46882 100644 --- a/database/users_chats_db.py +++ b/database/users_chats_db.py @@ -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}) diff --git a/misskaty/plugins/ban_user_or_chat.py b/misskaty/plugins/ban_user_or_chat.py index b7992f8c..ce705580 100644 --- a/misskaty/plugins/ban_user_or_chat.py +++ b/misskaty/plugins/ban_user_or_chat.py @@ -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)