Skip to content

Commit

Permalink
Fix http error in IMDB search, add instatus user for channel (user re…
Browse files Browse the repository at this point in the history
…quest)

Signed-off-by: Yasir Aris M <[email protected]>
  • Loading branch information
yasirarism committed Oct 23, 2023
1 parent 6c763e1 commit 8d9e111
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
12 changes: 6 additions & 6 deletions misskaty/plugins/imdb_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 - <code>{exc}</code>", disable_web_page_preview=True)
await k.edit_caption(f"HTTP Exception for IMDB Search - <code>{exc}</code>")
except (MessageIdInvalid, MessageNotModified):
pass
except Exception as err:
Expand Down Expand Up @@ -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 - <code>{exc}</code>", disable_web_page_preview=True)
await k.edit_caption(f"HTTP Exception for IMDB Search - <code>{exc}</code>")
except (MessageIdInvalid, MessageNotModified):
pass
except Exception as err:
Expand Down Expand Up @@ -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 - <code>{exc}</code>", disable_web_page_preview=True)
await query.message.edit_caption(f"HTTP Exception for IMDB Search - <code>{exc}</code>")
except (MessageIdInvalid, MessageNotModified):
pass
except Exception as err:
Expand Down Expand Up @@ -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 - <code>{exc}</code>", disable_web_page_preview=True)
await query.message.edit_caption(f"HTTP Exception for IMDB Search - <code>{exc}</code>")
except (MessageIdInvalid, MessageNotModified):
pass
except Exception as err:
Expand Down Expand Up @@ -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 - <code>{exc}</code>", disable_web_page_preview=True)
await query.message.edit_caption(f"HTTP Exception for IMDB Search - <code>{exc}</code>")
except AttributeError:
await query.message.edit_caption("Maaf, gagal mendapatkan info data dari IMDB.")
except (MessageNotModified, MessageIdInvalid):
Expand Down Expand Up @@ -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 - <code>{exc}</code>", disable_web_page_preview=True)
await query.message.edit_caption(f"HTTP Exception for IMDB Search - <code>{exc}</code>")
except AttributeError:
await query.message.edit_caption("Sorry, failed getting data from IMDB.")
except (MessageNotModified, MessageIdInvalid):
Expand Down
20 changes: 6 additions & 14 deletions misskaty/plugins/inkick_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.**"
Expand All @@ -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(
Expand All @@ -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.**"
Expand All @@ -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(
Expand All @@ -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."
Expand All @@ -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(
Expand Down

0 comments on commit 8d9e111

Please sign in to comment.