mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2026-01-03 19:14:51 +00:00
parent
370795d4c7
commit
22b0e3ba35
10 changed files with 109 additions and 96 deletions
|
|
@ -4,9 +4,7 @@ gbansdb = dbname.gban
|
||||||
|
|
||||||
async def is_gbanned_user(user_id: int) -> bool:
|
async def is_gbanned_user(user_id: int) -> bool:
|
||||||
user = await gbansdb.find_one({"user_id": user_id})
|
user = await gbansdb.find_one({"user_id": user_id})
|
||||||
if not user:
|
return bool(user)
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
async def add_gban_user(user_id: int):
|
async def add_gban_user(user_id: int):
|
||||||
is_gbanned = await is_gbanned_user(user_id)
|
is_gbanned = await is_gbanned_user(user_id)
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,7 @@ async def update_karma(chat_id: int, name: str, karma: dict):
|
||||||
|
|
||||||
async def is_karma_on(chat_id: int) -> bool:
|
async def is_karma_on(chat_id: int) -> bool:
|
||||||
chat = await karmadb.find_one({"chat_id_toggle": chat_id})
|
chat = await karmadb.find_one({"chat_id_toggle": chat_id})
|
||||||
if not chat:
|
return not chat
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
async def karma_on(chat_id: int):
|
async def karma_on(chat_id: int):
|
||||||
|
|
|
||||||
|
|
@ -34,12 +34,11 @@ def get_readable_time(seconds: int) -> str:
|
||||||
|
|
||||||
|
|
||||||
def get_readable_bitrate(bitrate_kbps):
|
def get_readable_bitrate(bitrate_kbps):
|
||||||
if bitrate_kbps > 10000:
|
return (
|
||||||
bitrate = str(round(bitrate_kbps / 1000, 2)) + " " + "Mb/s"
|
f"{str(round(bitrate_kbps / 1000, 2))} Mb/s"
|
||||||
else:
|
if bitrate_kbps > 10000
|
||||||
bitrate = str(round(bitrate_kbps, 2)) + " " + "kb/s"
|
else f"{str(round(bitrate_kbps, 2))} kb/s"
|
||||||
|
)
|
||||||
return bitrate
|
|
||||||
|
|
||||||
|
|
||||||
def get_readable_time2(seconds: int) -> str:
|
def get_readable_time2(seconds: int) -> str:
|
||||||
|
|
|
||||||
|
|
@ -38,12 +38,11 @@ async def kusonimeBypass(url: str, slug=None):
|
||||||
e = traceback.format_exc()
|
e = traceback.format_exc()
|
||||||
LOGGER.error(e)
|
LOGGER.error(e)
|
||||||
title, season, tipe, status_anime, ep, score, duration, rilis = "None", "None", "None", "None", 0, 0, 0, "None"
|
title, season, tipe, status_anime, ep, score, duration, rilis = "None", "None", "None", "None", 0, 0, 0, "None"
|
||||||
num = 1
|
|
||||||
genre = []
|
genre = []
|
||||||
for _genre in soup.select("#venkonten > div.vezone > div.venser > div.venutama > div.lexot > div.info > p:nth-child(2)"):
|
for _genre in soup.select("#venkonten > div.vezone > div.venser > div.venutama > div.lexot > div.info > p:nth-child(2)"):
|
||||||
gen = _genre.text.split(":").pop().strip().split(", ")
|
gen = _genre.text.split(":").pop().strip().split(", ")
|
||||||
genre = gen
|
genre = gen
|
||||||
for smokedl in soup.find("div", {"class": "dlbodz"}).find_all("div", {"class": "smokeddlrh"}):
|
for num, smokedl in enumerate(soup.find("div", {"class": "dlbodz"}).find_all("div", {"class": "smokeddlrh"}), start=1):
|
||||||
mendata = {"name": title, "links": []}
|
mendata = {"name": title, "links": []}
|
||||||
for smokeurl in smokedl.find_all("div", {"class": "smokeurlrh"}):
|
for smokeurl in smokedl.find_all("div", {"class": "smokeurlrh"}):
|
||||||
quality = smokeurl.find("strong").text
|
quality = smokeurl.find("strong").text
|
||||||
|
|
@ -54,12 +53,25 @@ async def kusonimeBypass(url: str, slug=None):
|
||||||
links.append({"client": client, "url": url})
|
links.append({"client": client, "url": url})
|
||||||
mendata["links"].append({"quality": quality, "link_download": links})
|
mendata["links"].append({"quality": quality, "link_download": links})
|
||||||
data.append(mendata)
|
data.append(mendata)
|
||||||
num += 1
|
result |= {
|
||||||
result.update({"error": False, "title": title, "thumb": thumb, "genre": genre, "genre_string": ", ".join(genre), "status_anime": status_anime, "season": season, "tipe": tipe, "ep": ep, "score": score, "duration": duration, "rilis": rilis, "data": data})
|
"error": False,
|
||||||
|
"title": title,
|
||||||
|
"thumb": thumb,
|
||||||
|
"genre": genre,
|
||||||
|
"genre_string": ", ".join(genre),
|
||||||
|
"status_anime": status_anime,
|
||||||
|
"season": season,
|
||||||
|
"tipe": tipe,
|
||||||
|
"ep": ep,
|
||||||
|
"score": score,
|
||||||
|
"duration": duration,
|
||||||
|
"rilis": rilis,
|
||||||
|
"data": data,
|
||||||
|
}
|
||||||
except Exception:
|
except Exception:
|
||||||
err = traceback.format_exc()
|
err = traceback.format_exc()
|
||||||
LOGGER.error(err)
|
LOGGER.error(err)
|
||||||
result.update({"error": True, "error_message": err})
|
result |= {"error": True, "error_message": err}
|
||||||
finally:
|
finally:
|
||||||
await http.delete(_url)
|
await http.delete(_url)
|
||||||
return result
|
return result
|
||||||
|
|
@ -68,6 +80,7 @@ async def kusonimeBypass(url: str, slug=None):
|
||||||
async def byPassPh(url: str, name: str):
|
async def byPassPh(url: str, name: str):
|
||||||
kusonime = await kusonimeBypass(url)
|
kusonime = await kusonimeBypass(url)
|
||||||
results = {"error": True, "error_message": kusonime}
|
results = {"error": True, "error_message": kusonime}
|
||||||
|
if not kusonime["error"]:
|
||||||
template = """
|
template = """
|
||||||
<img src={{{thumb}}}>
|
<img src={{{thumb}}}>
|
||||||
|
|
||||||
|
|
@ -92,13 +105,12 @@ async def byPassPh(url: str, name: str):
|
||||||
<br>
|
<br>
|
||||||
{{/data}}
|
{{/data}}
|
||||||
""".strip()
|
""".strip()
|
||||||
if not kusonime["error"]:
|
|
||||||
html = chevron.render(template, kusonime)
|
html = chevron.render(template, kusonime)
|
||||||
telegraph = Telegraph()
|
telegraph = Telegraph()
|
||||||
if not telegraph.get_access_token():
|
if not telegraph.get_access_token():
|
||||||
await telegraph.create_account(short_name=BOT_USERNAME)
|
await telegraph.create_account(short_name=BOT_USERNAME)
|
||||||
page = await telegraph.create_page(f"{kusonime.get('title')} By {escape(name)}", html_content=html)
|
page = await telegraph.create_page(f"{kusonime.get('title')} By {escape(name)}", html_content=html)
|
||||||
results.update({"error": False, "url": "https://telegra.ph/{}".format(page["path"])})
|
results |= {"error": False, "url": f'https://telegra.ph/{page["path"]}'}
|
||||||
del results["error_message"]
|
del results["error_message"]
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ def html_builder(title: str, text: str) -> str:
|
||||||
infobox = "<span class='container infobox'>"
|
infobox = "<span class='container infobox'>"
|
||||||
subtitlebox = "<span class='container subtitlebox'>"
|
subtitlebox = "<span class='container subtitlebox'>"
|
||||||
icon = "<img class='icons' src={icon_url} width='35px' height='35px' alt='' >"
|
icon = "<img class='icons' src={icon_url} width='35px' height='35px' alt='' >"
|
||||||
html_msg = "<body>" + heading.format(content=title)
|
html_msg = f"<body>{heading.format(content=title)}"
|
||||||
|
|
||||||
for line in text.splitlines():
|
for line in text.splitlines():
|
||||||
if ":" not in line and bool(line):
|
if ":" not in line and bool(line):
|
||||||
|
|
@ -194,14 +194,10 @@ def html_builder(title: str, text: str) -> str:
|
||||||
html_msg += subtitlebox if "Text #" in line else infobox
|
html_msg += subtitlebox if "Text #" in line else infobox
|
||||||
|
|
||||||
elif ":" in line:
|
elif ":" in line:
|
||||||
if "Attachments" in line:
|
if "Attachments" not in line and "ErrorDetectionType" not in line:
|
||||||
pass
|
|
||||||
elif "ErrorDetectionType" in line:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
html_msg += f"<div><code>{line.strip()}</code></div>"
|
html_msg += f"<div><code>{line.strip()}</code></div>"
|
||||||
|
|
||||||
elif not bool(line):
|
else:
|
||||||
html_msg += "</span>"
|
html_msg += "</span>"
|
||||||
|
|
||||||
html_msg += "</span>"
|
html_msg += "</span>"
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,17 @@ async def down_page(url):
|
||||||
releases = ""
|
releases = ""
|
||||||
for i in range(2):
|
for i in range(2):
|
||||||
r = release[i].text.strip()
|
r = release[i].text.strip()
|
||||||
releases = releases + f"\n{r}"
|
releases = f"{releases}\n{r}"
|
||||||
except Exception:
|
except Exception:
|
||||||
releases = ""
|
releases = ""
|
||||||
|
|
||||||
response = {"title": title, "imdb": imdb, "poster": poster, "author_name": author_name, "author_url": author_link, "download_url": download_url, "comments": comments, "releases": releases}
|
return {
|
||||||
return response
|
"title": title,
|
||||||
|
"imdb": imdb,
|
||||||
|
"poster": poster,
|
||||||
|
"author_name": author_name,
|
||||||
|
"author_url": author_link,
|
||||||
|
"download_url": download_url,
|
||||||
|
"comments": comments,
|
||||||
|
"releases": releases,
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,9 +93,9 @@ async def tg_lock(message, permissions: list, perm: str, lock: bool):
|
||||||
if perm not in permissions:
|
if perm not in permissions:
|
||||||
return await message.reply_text("Already locked.")
|
return await message.reply_text("Already locked.")
|
||||||
permissions.remove(perm)
|
permissions.remove(perm)
|
||||||
else:
|
elif perm in permissions:
|
||||||
if perm in permissions:
|
|
||||||
return await message.reply_text("Already Unlocked.")
|
return await message.reply_text("Already Unlocked.")
|
||||||
|
else:
|
||||||
permissions.append(perm)
|
permissions.append(perm)
|
||||||
|
|
||||||
permissions = {perm: True for perm in list(set(permissions))}
|
permissions = {perm: True for perm in list(set(permissions))}
|
||||||
|
|
@ -126,12 +126,7 @@ async def locks_func(_, message):
|
||||||
permissions = await current_chat_permissions(chat_id)
|
permissions = await current_chat_permissions(chat_id)
|
||||||
|
|
||||||
if parameter in data:
|
if parameter in data:
|
||||||
await tg_lock(
|
await tg_lock(message, permissions, data[parameter], state == "lock")
|
||||||
message,
|
|
||||||
permissions,
|
|
||||||
data[parameter],
|
|
||||||
bool(state == "lock"),
|
|
||||||
)
|
|
||||||
elif parameter == "all" and state == "lock":
|
elif parameter == "all" and state == "lock":
|
||||||
await app.set_chat_permissions(chat_id, ChatPermissions())
|
await app.set_chat_permissions(chat_id, ChatPermissions())
|
||||||
await message.reply_text(f"Locked Everything in {message.chat.title}")
|
await message.reply_text(f"Locked Everything in {message.chat.title}")
|
||||||
|
|
@ -161,10 +156,7 @@ async def locktypes(_, message):
|
||||||
if not permissions:
|
if not permissions:
|
||||||
return await message.reply_text("No Permissions.")
|
return await message.reply_text("No Permissions.")
|
||||||
|
|
||||||
perms = ""
|
perms = "".join(f"__**{i}**__\n" for i in permissions)
|
||||||
for i in permissions:
|
|
||||||
perms += f"__**{i}**__\n"
|
|
||||||
|
|
||||||
await message.reply_text(perms)
|
await message.reply_text(perms)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -180,8 +172,7 @@ async def url_detector(_, message):
|
||||||
if user.id in mods or user.id in SUDO:
|
if user.id in mods or user.id in SUDO:
|
||||||
return
|
return
|
||||||
|
|
||||||
check = get_urls_from_text(text)
|
if check := get_urls_from_text(text):
|
||||||
if check:
|
|
||||||
permissions = await current_chat_permissions(chat_id)
|
permissions = await current_chat_permissions(chat_id)
|
||||||
if "can_add_web_page_previews" not in permissions:
|
if "can_add_web_page_previews" not in permissions:
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,13 @@ async def ceksub(self: Client, ctx: Message, strings):
|
||||||
@use_chat_lang()
|
@use_chat_lang()
|
||||||
async def convertsrt(self: Client, ctx: Message, strings):
|
async def convertsrt(self: Client, ctx: Message, strings):
|
||||||
reply = ctx.reply_to_message
|
reply = ctx.reply_to_message
|
||||||
if reply and reply.document and (reply.document.file_name and reply.document.file_name.endswith((".vtt", ".ass", ".srt"))):
|
if (
|
||||||
|
not reply
|
||||||
|
or not reply.document
|
||||||
|
or not reply.document.file_name
|
||||||
|
or not reply.document.file_name.endswith((".vtt", ".ass", ".srt"))
|
||||||
|
):
|
||||||
|
return await ctx.reply_msg(strings("conv_sub_help").format(cmd=ctx.command[0]), del_in=6)
|
||||||
msg = await ctx.reply_msg(strings("convert_str"), quote=True)
|
msg = await ctx.reply_msg(strings("convert_str"), quote=True)
|
||||||
if not os.path.exists("downloads"):
|
if not os.path.exists("downloads"):
|
||||||
os.makedirs("downloads")
|
os.makedirs("downloads")
|
||||||
|
|
@ -143,8 +149,6 @@ async def convertsrt(self: Client, ctx: Message, strings):
|
||||||
os.remove(f"downloads/{filename}.{suffix}")
|
os.remove(f"downloads/{filename}.{suffix}")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
|
||||||
return await ctx.reply_msg(strings("conv_sub_help").format(cmd=ctx.command[0]), del_in=6)
|
|
||||||
|
|
||||||
|
|
||||||
@app.on_callback_query(filters.regex(r"^streamextract#"))
|
@app.on_callback_query(filters.regex(r"^streamextract#"))
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,16 @@ __HELP__ = "/ocr [reply to photo] - Read Text From Image"
|
||||||
@use_chat_lang()
|
@use_chat_lang()
|
||||||
async def ocr(self: Client, ctx: Message, strings):
|
async def ocr(self: Client, ctx: Message, strings):
|
||||||
reply = ctx.reply_to_message
|
reply = ctx.reply_to_message
|
||||||
if reply and (reply.sticker or reply.photo or reply.document and reply.document.mime_type.startswith("image")):
|
if (
|
||||||
|
not reply
|
||||||
|
or not reply.sticker
|
||||||
|
and not reply.photo
|
||||||
|
and (
|
||||||
|
not reply.document
|
||||||
|
or not reply.document.mime_type.startswith("image")
|
||||||
|
)
|
||||||
|
):
|
||||||
|
return await ctx.reply_msg(strings("no_photo").format(cmd=ctx.command[0]), quote=True)
|
||||||
msg = await ctx.reply_msg(strings("read_ocr"), quote=True)
|
msg = await ctx.reply_msg(strings("read_ocr"), quote=True)
|
||||||
try:
|
try:
|
||||||
file_path = await reply.download()
|
file_path = await reply.download()
|
||||||
|
|
@ -51,5 +60,3 @@ async def ocr(self: Client, ctx: Message, strings):
|
||||||
await msg.edit_msg(str(e))
|
await msg.edit_msg(str(e))
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
else:
|
|
||||||
return await ctx.reply_msg(strings("no_photo").format(cmd=ctx.command[0]), quote=True)
|
|
||||||
|
|
@ -411,11 +411,11 @@ async def getSame(msg, query, current_page, strings):
|
||||||
try:
|
try:
|
||||||
index = int(current_page - 1)
|
index = int(current_page - 1)
|
||||||
PageLen = len(SCRAP_DICT[msg.id][0])
|
PageLen = len(SCRAP_DICT[msg.id][0])
|
||||||
sameresult = ""
|
sameresult = "".join(
|
||||||
for c, i in enumerate(SCRAP_DICT[msg.id][0][index], start=1):
|
f"<b>{index * 6 + c}. <a href='{i['url']}'>{i['title']}</a>\n<b>Status:</b> {i['sta']}\n</b>Rating:</b> {i['rate']}\n\n"
|
||||||
sameresult += f"<b>{index*6+c}. <a href='{i['url']}'>{i['title']}</a>\n<b>Status:</b> {i['sta']}\n</b>Rating:</b> {i['rate']}\n\n"
|
for c, i in enumerate(SCRAP_DICT[msg.id][0][index], start=1)
|
||||||
IGNORE_CHAR = "[]"
|
)
|
||||||
sameresult = "".join(i for i in sameresult if not i in IGNORE_CHAR)
|
sameresult = "".join(i for i in sameresult if i not in "[]")
|
||||||
return sameresult, PageLen
|
return sameresult, PageLen
|
||||||
except (IndexError, KeyError):
|
except (IndexError, KeyError):
|
||||||
await msg.edit_msg(strings("no_result"), del_in=5)
|
await msg.edit_msg(strings("no_result"), del_in=5)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue