From e1112e7a327857e73b507182728c7c2d18e5a017 Mon Sep 17 00:00:00 2001 From: yasirarism <55983182+yasirarism@users.noreply.github.com> Date: Fri, 16 Jun 2023 03:45:38 +0000 Subject: [PATCH] Try fix unban button --- misskaty/__init__.py | 2 +- misskaty/plugins/admin.py | 15 +++++++++------ misskaty/plugins/locks.py | 4 ++-- misskaty/plugins/web_scraper.py | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/misskaty/__init__.py b/misskaty/__init__.py index 1e8bea76..7f9088b1 100644 --- a/misskaty/__init__.py +++ b/misskaty/__init__.py @@ -28,7 +28,7 @@ MOD_NOLOAD = ["subscene_dl"] HELPABLE = {} cleanmode = {} botStartTime = time.time() -misskaty_version = "v2.4 - Stable" +misskaty_version = "v2.5 - Stable" pymonclient = MongoClient(DATABASE_URI) diff --git a/misskaty/plugins/admin.py b/misskaty/plugins/admin.py index 614cedc8..37b7af6c 100644 --- a/misskaty/plugins/admin.py +++ b/misskaty/plugins/admin.py @@ -218,7 +218,7 @@ async def banFunc(client, message, strings): @adminsOnly("can_restrict_members") @ratelimiter @use_chat_lang() -async def unban_func(_, message, strings): +async def unban_func(self, message, strings): if not message.from_user: return # we don't need reasons for unban, also, we @@ -231,7 +231,7 @@ async def unban_func(_, message, strings): return await message.reply_text(strings("unban_channel_err")) if len(message.command) == 2: - user = message.text.split(None, 1)[1] + user = int(message.text.split(None, 1)[1]) elif len(message.command) == 1 and reply: user = message.reply_to_message.from_user.id else: @@ -544,7 +544,7 @@ async def warn_user(client, message, strings): get_warn(chat_id, await int_to_alpha(user_id)), ) mention = user.mention - keyboard = ikb({strings("rmwarn_btn"): f"unwarn_{user_id}"}) + keyboard = ikb({strings("rm_warn_btn"): f"unwarn_{user_id}"}) warns = warns["warns"] if warns else 0 if message.command[0][0] == "d": await message.reply_to_message.delete() @@ -620,12 +620,15 @@ async def unban_user(_, cq, strings): strings("no_permission_error").format(permissions=permission), show_alert=True, ) - user_id = cq.data.split("_")[1] + user_id = int(cq.data.split("_")[1]) text = cq.message.text.markdown text = f"~~{text}~~\n\n" text += strings("unban_msg").format(mention=from_user.mention) - await cq.message.chat.unban_member(user_id) - await cq.message.edit(text) + try: + await cq.message.chat.unban_member(user_id) + await cq.message.edit(text) + except Exception as e: + await cq.answer(str(e)) # Remove Warn diff --git a/misskaty/plugins/locks.py b/misskaty/plugins/locks.py index 951f55b3..377fb835 100644 --- a/misskaty/plugins/locks.py +++ b/misskaty/plugins/locks.py @@ -185,9 +185,9 @@ async def url_detector(_, message): permissions = await current_chat_permissions(chat_id) if "can_add_web_page_previews" not in permissions: try: - await message.delete() + await message.delete_msg() except Exception: - await message.reply_text( + await message.reply_msg( "This message contains a URL, " + "but i don't have enough permissions to delete it" ) \ No newline at end of file diff --git a/misskaty/plugins/web_scraper.py b/misskaty/plugins/web_scraper.py index 706c56b0..08403412 100644 --- a/misskaty/plugins/web_scraper.py +++ b/misskaty/plugins/web_scraper.py @@ -236,7 +236,7 @@ async def getDataSavefilm21(msg, kueri, CurrentPage, user, strings): data = await http.get(f"{web['savefilm21']}/?s={kueri}", headers=headers, follow_redirects=True) except Exception as err: await msg.edit_msg(strings("err_getweb").format(err=err)) - return None, None + return None, 0, None text = BeautifulSoup(data, "lxml") entry = text.find_all(class_="entry-header") if "Tidak Ditemukan" in entry[0].text: