From 8d9e111c0450a45a526971520c81be5d17461af3 Mon Sep 17 00:00:00 2001 From: Yasir Aris M Date: Mon, 23 Oct 2023 23:11:34 +0700 Subject: [PATCH] Fix http error in IMDB search, add instatus user for channel (user request) Signed-off-by: Yasir Aris M --- misskaty/plugins/imdb_search.py | 12 ++++++------ misskaty/plugins/inkick_user.py | 20 ++++++-------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/misskaty/plugins/imdb_search.py b/misskaty/plugins/imdb_search.py index 593fd8dc9a..343ea4c429 100644 --- a/misskaty/plugins/imdb_search.py +++ b/misskaty/plugins/imdb_search.py @@ -181,7 +181,7 @@ async def imdb_search_id(kueri, message): buttons.add(*BTN) await k.edit_caption(msg, reply_markup=buttons) except httpx.HTTPError as exc: - await k.edit_caption(f"HTTP Exception for IMDB Search - {exc}", disable_web_page_preview=True) + await k.edit_caption(f"HTTP Exception for IMDB Search - {exc}") except (MessageIdInvalid, MessageNotModified): pass except Exception as err: @@ -243,7 +243,7 @@ async def imdb_search_en(kueri, message): buttons.add(*BTN) await k.edit_caption(msg, reply_markup=buttons) except httpx.HTTPError as exc: - await k.edit_caption(f"HTTP Exception for IMDB Search - {exc}", disable_web_page_preview=True) + await k.edit_caption(f"HTTP Exception for IMDB Search - {exc}") except (MessageIdInvalid, MessageNotModified): pass except Exception as err: @@ -311,7 +311,7 @@ async def imdbcari(_, query: CallbackQuery): buttons.add(*BTN) await query.message.edit_caption(msg, reply_markup=buttons) except httpx.HTTPError as exc: - await query.message.edit_caption(f"HTTP Exception for IMDB Search - {exc}", disable_web_page_preview=True) + await query.message.edit_caption(f"HTTP Exception for IMDB Search - {exc}") except (MessageIdInvalid, MessageNotModified): pass except Exception as err: @@ -368,7 +368,7 @@ async def imdbcari(_, query: CallbackQuery): buttons.add(*BTN) await query.message.edit_caption(msg, reply_markup=buttons) except httpx.HTTPError as exc: - await query.message.edit_caption(f"HTTP Exception for IMDB Search - {exc}", disable_web_page_preview=True) + await query.message.edit_caption(f"HTTP Exception for IMDB Search - {exc}") except (MessageIdInvalid, MessageNotModified): pass except Exception as err: @@ -532,7 +532,7 @@ async def imdb_id_callback(self: Client, query: CallbackQuery): res_str, parse_mode=enums.ParseMode.HTML, reply_markup=markup ) except httpx.HTTPError as exc: - await query.message.edit_caption(f"HTTP Exception for IMDB Search - {exc}", disable_web_page_preview=True) + await query.message.edit_caption(f"HTTP Exception for IMDB Search - {exc}") except AttributeError: await query.message.edit_caption("Maaf, gagal mendapatkan info data dari IMDB.") except (MessageNotModified, MessageIdInvalid): @@ -696,7 +696,7 @@ async def imdb_en_callback(self: Client, query: CallbackQuery): res_str, parse_mode=enums.ParseMode.HTML, reply_markup=markup ) except httpx.HTTPError as exc: - await query.message.edit_caption(f"HTTP Exception for IMDB Search - {exc}", disable_web_page_preview=True) + await query.message.edit_caption(f"HTTP Exception for IMDB Search - {exc}") except AttributeError: await query.message.edit_caption("Sorry, failed getting data from IMDB.") except (MessageNotModified, MessageIdInvalid): diff --git a/misskaty/plugins/inkick_user.py b/misskaty/plugins/inkick_user.py index 3973b6803a..f7f6e852f2 100644 --- a/misskaty/plugins/inkick_user.py +++ b/misskaty/plugins/inkick_user.py @@ -24,10 +24,6 @@ ) @app.adminsOnly("can_restrict_members") async def inkick(_, message): - if message.sender_chat: - return await message.reply_msg( - "This feature not available for channel.", del_in=4 - ) user = await app.get_chat_member(message.chat.id, message.from_user.id) if user.status.value in ("administrator", "owner"): if len(message.command) > 1: @@ -56,6 +52,8 @@ async def inkick(_, message): break except FloodWait as e: await sleep(e.value) + await message.chat.ban_member(member.user.id) + await message.chat.unban_member(member.user.id) try: await sent_message.edit( f"✔️ **Berhasil menendang {count} pengguna berdasarkan argumen.**" @@ -81,10 +79,6 @@ async def inkick(_, message): ) @app.adminsOnly("can_restrict_members") async def uname(_, message): - if message.sender_chat: - return await message.reply_msg( - "This feature not available for channel.", del_in=4 - ) user = await app.get_chat_member(message.chat.id, message.from_user.id) if user.status.value in ("administrator", "owner"): sent_message = await message.reply_text( @@ -109,6 +103,8 @@ async def uname(_, message): break except FloodWait as e: await sleep(e.value) + await message.chat.ban_member(member.user.id) + await message.chat.unban_member(member.user.id) try: await sent_message.edit( f"✔️ **Berhasil menendang {count} pengguna berdasarkan argumen.**" @@ -131,10 +127,6 @@ async def uname(_, message): ) @app.adminsOnly("can_restrict_members") async def rm_delacc(_, message): - if message.sender_chat: - return await message.reply_msg( - "This feature not available for channel.", del_in=4 - ) user = await app.get_chat_member(message.chat.id, message.from_user.id) if user.status.value in ("administrator", "owner"): sent_message = await message.reply_text( @@ -158,6 +150,8 @@ async def rm_delacc(_, message): break except FloodWait as e: await sleep(e.value) + await message.chat.ban_member(member.user.id) + await message.chat.unban_member(member.user.id) if count == 0: return await sent_message.edit_msg( "There are no deleted accounts in this chat." @@ -176,8 +170,6 @@ async def rm_delacc(_, message): ) @app.adminsOnly("can_restrict_members") async def instatus(client, message): - if message.sender_chat: - return await message.reply_msg("Not supported channel.", del_in=4) bstat = await app.get_chat_member(message.chat.id, client.me.id) if bstat.status.value != "administrator": return await message.reply_msg(