mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2025-12-29 09:44:50 +00:00
Remove task timeout since it make bot slow, i will try find solution later
This commit is contained in:
parent
174a8e1ac8
commit
de72f6077a
5 changed files with 26 additions and 78 deletions
|
|
@ -63,7 +63,12 @@ async def anonymous_admin_verification(
|
|||
cb = ANON.pop(
|
||||
int(f"{CallbackQuery.message.chat.id}{CallbackQuery.data.split('.')[1]}")
|
||||
)
|
||||
member = await CallbackQuery.message.chat.get_member(CallbackQuery.from_user.id)
|
||||
try:
|
||||
member = await CallbackQuery.message.chat.get_member(CallbackQuery.from_user.id)
|
||||
except pyrogram.errors.exceptions.forbidden_403.ChatAdminRequired:
|
||||
return await CallbackQuery.message.edit_text(
|
||||
"I must be admin to execute this task, or i will leave from this group.",
|
||||
)
|
||||
if member.status not in (
|
||||
pyrogram.enums.ChatMemberStatus.OWNER,
|
||||
pyrogram.enums.ChatMemberStatus.ADMINISTRATOR,
|
||||
|
|
@ -99,7 +104,7 @@ async def anonymous_admin_verification(
|
|||
await cb[1](self, cb[0])
|
||||
except pyrogram.errors.exceptions.forbidden_403.ChatAdminRequired:
|
||||
return await CallbackQuery.message.edit_text(
|
||||
"I must be admin to execute this Command",
|
||||
"I must be admin to execute this task, or i will leave from this group.",
|
||||
)
|
||||
except BaseException as e:
|
||||
return await handle_error(e, CallbackQuery)
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ class RateLimiter:
|
|||
self.second_rate = RequestRate(1, Duration.SECOND)
|
||||
|
||||
# 15 requests per minute.
|
||||
self.minute_rate = RequestRate(15, Duration.MINUTE)
|
||||
self.minute_rate = RequestRate(60, Duration.MINUTE)
|
||||
|
||||
# 100 requests per hour
|
||||
self.hourly_rate = RequestRate(100, Duration.HOUR)
|
||||
self.hourly_rate = RequestRate(300, Duration.HOUR)
|
||||
|
||||
# 500 requests per day
|
||||
self.daily_rate = RequestRate(500, Duration.DAY)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ from pyrogram.types import (
|
|||
from database.imdb_db import add_imdbset, is_imdbset, remove_imdbset
|
||||
from misskaty import app
|
||||
from misskaty.core.decorator.ratelimiter import ratelimiter
|
||||
from misskaty.core.misskaty_patch.listen.listen import ListenerTimeout
|
||||
from misskaty.helper import GENRES_EMOJI, Cache, get_random_string, http, search_jw
|
||||
from utils import demoji
|
||||
|
||||
|
|
@ -64,29 +63,19 @@ async def imdb_choose(_, ctx: Message):
|
|||
return await imdb_search_id(kuery, ctx)
|
||||
buttons = InlineKeyboard()
|
||||
ranval = get_random_string(4)
|
||||
LIST_CARI.add(ranval, kuery, timeout=180)
|
||||
LIST_CARI.add(ranval, kuery, timeout=30)
|
||||
buttons.row(
|
||||
InlineButton("🇺🇸 English", f"imdbcari#eng#{ranval}#{ctx.from_user.id}"),
|
||||
InlineButton("🇮🇩 Indonesia", f"imdbcari#ind#{ranval}#{ctx.from_user.id}"),
|
||||
)
|
||||
buttons.row(InlineButton("🚩 Set Default Language", f"imdbset#{ctx.from_user.id}"))
|
||||
buttons.row(InlineButton("❌ Close", f"close#{ctx.from_user.id}"))
|
||||
msg = await ctx.reply_photo(
|
||||
await ctx.reply_photo(
|
||||
"https://telegra.ph/file/270955ef0d1a8a16831a9.jpg",
|
||||
caption=f"Hi {ctx.from_user.mention}, Please select the language you want to use on IMDB Search. If you want use default lang for every user, click third button. So no need click select lang if use CMD.",
|
||||
reply_markup=buttons,
|
||||
quote=True,
|
||||
)
|
||||
try:
|
||||
await msg.wait_for_click(from_user_id=ctx.from_user.id, timeout=30)
|
||||
except ListenerTimeout:
|
||||
del LIST_CARI[ranval]
|
||||
try:
|
||||
await msg.edit_caption(
|
||||
"😶🌫️ Callback Query Timeout. Task Has Been Canceled!"
|
||||
)
|
||||
except MessageIdInvalid:
|
||||
pass
|
||||
|
||||
|
||||
@app.on_cb("imdbset")
|
||||
|
|
@ -106,18 +95,9 @@ async def imdblangset(_, query: CallbackQuery):
|
|||
InlineButton("🗑 Remove UserSetting", f"setimdb#rm#{query.from_user.id}")
|
||||
)
|
||||
buttons.row(InlineButton("❌ Close", f"close#{query.from_user.id}"))
|
||||
msg = await query.message.edit_caption(
|
||||
await query.message.edit_caption(
|
||||
"<i>Please select available language below..</i>", reply_markup=buttons
|
||||
)
|
||||
try:
|
||||
await msg.wait_for_click(from_user_id=int(uid), timeout=30)
|
||||
except ListenerTimeout:
|
||||
try:
|
||||
await msg.edit_caption(
|
||||
"😶🌫️ Callback Query Timeout. Task Has Been Canceled!"
|
||||
)
|
||||
except MessageIdInvalid:
|
||||
pass
|
||||
|
||||
|
||||
@app.on_cb("setimdb")
|
||||
|
|
@ -196,14 +176,7 @@ async def imdb_search_id(kueri, message):
|
|||
)
|
||||
)
|
||||
buttons.add(*BTN)
|
||||
msg = await k.edit_caption(msg, reply_markup=buttons)
|
||||
try:
|
||||
await msg.wait_for_click(from_user_id=message.from_user.id, timeout=30)
|
||||
except ListenerTimeout:
|
||||
try:
|
||||
await msg.edit_caption("😶🌫️ Waktu Habis. Task Telah Dibatalkan!")
|
||||
except MessageIdInvalid:
|
||||
pass
|
||||
await k.edit_caption(msg, reply_markup=buttons)
|
||||
except Exception as err:
|
||||
await k.edit_caption(
|
||||
f"Ooppss, gagal mendapatkan daftar judul di IMDb. Mungkin terkena rate limit atau down.\n\n<b>ERROR:</b> <code>{err}</code>"
|
||||
|
|
@ -260,14 +233,7 @@ async def imdb_search_en(kueri, message):
|
|||
)
|
||||
)
|
||||
buttons.add(*BTN)
|
||||
msg = await k.edit_caption(msg, reply_markup=buttons)
|
||||
try:
|
||||
await msg.wait_for_click(from_user_id=message.from_user.id, timeout=30)
|
||||
except ListenerTimeout:
|
||||
try:
|
||||
await msg.edit_caption("😶🌫️ Timeout. Task Has Been Cancelled!")
|
||||
except MessageIdInvalid:
|
||||
pass
|
||||
await k.edit_caption(msg, reply_markup=buttons)
|
||||
except Exception as err:
|
||||
await k.edit_caption(
|
||||
f"Failed when requesting movies title. Maybe got rate limit or down.\n\n<b>ERROR:</b> <code>{err}</code>"
|
||||
|
|
@ -326,16 +292,7 @@ async def imdbcari(_, query: CallbackQuery):
|
|||
)
|
||||
)
|
||||
buttons.add(*BTN)
|
||||
try:
|
||||
msg = await query.message.edit_caption(msg, reply_markup=buttons)
|
||||
await msg.wait_for_click(from_user_id=int(uid), timeout=30)
|
||||
except ListenerTimeout:
|
||||
try:
|
||||
await msg.edit_caption("😶🌫️ Waktu Habis. Task Telah Dibatalkan!")
|
||||
except MessageIdInvalid:
|
||||
await msg.reply("😶🌫️ Waktu Habis. Task Telah Dibatalkan!")
|
||||
except MessageIdInvalid:
|
||||
pass
|
||||
await query.message.edit_caption(msg, reply_markup=buttons)
|
||||
except Exception as err:
|
||||
await query.message.edit_caption(
|
||||
f"Ooppss, gagal mendapatkan daftar judul di IMDb. Mungkin terkena rate limit atau down.\n\n<b>ERROR:</b> <code>{err}</code>"
|
||||
|
|
@ -387,16 +344,7 @@ async def imdbcari(_, query: CallbackQuery):
|
|||
)
|
||||
)
|
||||
buttons.add(*BTN)
|
||||
try:
|
||||
msg = await query.message.edit_caption(msg, reply_markup=buttons)
|
||||
await msg.wait_for_click(from_user_id=int(uid), timeout=30)
|
||||
except ListenerTimeout:
|
||||
try:
|
||||
await msg.edit_caption("😶🌫️ Timeout. Task Has Been Cancelled!")
|
||||
except MessageIdInvalid:
|
||||
await msg.reply("😶🌫️ Timeout. Task Has Been Cancelled!")
|
||||
except MessageIdInvalid:
|
||||
pass
|
||||
await query.message.edit_caption(msg, reply_markup=buttons)
|
||||
except Exception as err:
|
||||
await query.message.edit_caption(
|
||||
f"Failed when requesting movies title. Maybe got rate limit or down.\n\n<b>ERROR:</b> <code>{err}</code>"
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ async def locktypes(_, message):
|
|||
|
||||
@app.on_message(filters.text & ~filters.private, group=69)
|
||||
async def url_detector(_, message):
|
||||
user = message.from_user
|
||||
user = message.from_user or message.sender_chat
|
||||
chat_id = message.chat.id
|
||||
text = message.text.lower().strip()
|
||||
|
||||
|
|
|
|||
|
|
@ -335,26 +335,21 @@ async def getDataSavefilm21(msg, kueri, CurrentPage, user, strings):
|
|||
async def getDataLendrive(msg, kueri, CurrentPage, user, strings):
|
||||
if not SCRAP_DICT.get(msg.id):
|
||||
try:
|
||||
data = await http.get(
|
||||
f"{web['lendrive']}/?s={kueri}", headers=headers, follow_redirects=True
|
||||
)
|
||||
if query:
|
||||
data = await http.get(f"{web['lendrive']}/?s={query}", headers=headers, follow_redirects=True)
|
||||
else:
|
||||
data = await http.get(web["lendrive"], headers=headers, follow_redirects=True)
|
||||
except Exception as err:
|
||||
await msg.edit_msg(strings("err_getweb").format(err=err))
|
||||
return None, None
|
||||
soup = BeautifulSoup(data, "lxml")
|
||||
res = BeautifulSoup(data, "lxml")
|
||||
lenddata = []
|
||||
for o in soup.find_all(class_="bsx"):
|
||||
for o in res.find_all(class_="bsx"):
|
||||
title = o.find("a")["title"]
|
||||
link = o.find("a")["href"]
|
||||
status = o.find(class_="epx").text
|
||||
kualitas = (
|
||||
o.find(class_="typez TV").text
|
||||
if o.find(class_="typez TV")
|
||||
else o.find(class_="typez BD")
|
||||
)
|
||||
lenddata.append(
|
||||
{"judul": title, "link": link, "quality": kualitas, "status": status}
|
||||
)
|
||||
status = o.find(class_="epx").text if o.find(class_="epx") else "Not Provided by BOT"
|
||||
kualitas = o.find(class_="typez TV").text if o.find(class_="typez TV") else o.find(class_="typez BD")
|
||||
lenddata.append({"judul": title, "link": link, "quality": kualitas, "status": status})
|
||||
if not lenddata:
|
||||
await msg.edit_msg(strings("no_result"), del_in=5)
|
||||
return None, 0, None
|
||||
|
|
|
|||
Loading…
Reference in a new issue