|
|
@@ -36,19 +36,32 @@ from pykeyboard import InlineKeyboard
|
|
|
from pyrogram import __version__ as pyrover
|
|
|
from pyrogram import filters
|
|
|
from pyrogram.raw.functions import Ping
|
|
|
-from pyrogram.types import (InlineKeyboardButton, InlineQueryResultArticle,
|
|
|
- InlineQueryResultPhoto, InputTextMessageContent)
|
|
|
+from pyrogram.types import (
|
|
|
+ InlineKeyboardButton,
|
|
|
+ InlineQueryResultArticle,
|
|
|
+ InlineQueryResultPhoto,
|
|
|
+ InputTextMessageContent,
|
|
|
+)
|
|
|
from search_engine_parser import GoogleSearch
|
|
|
|
|
|
-from wbb import (BOT_USERNAME, MESSAGE_DUMP_CHAT, SUDOERS, USERBOT_ID,
|
|
|
- USERBOT_NAME, USERBOT_USERNAME, app, app2, arq)
|
|
|
+from wbb import (
|
|
|
+ BOT_USERNAME,
|
|
|
+ MESSAGE_DUMP_CHAT,
|
|
|
+ SUDOERS,
|
|
|
+ USERBOT_ID,
|
|
|
+ USERBOT_NAME,
|
|
|
+ USERBOT_USERNAME,
|
|
|
+ app,
|
|
|
+ app2,
|
|
|
+ arq,
|
|
|
+)
|
|
|
from wbb.core.types import InlineQueryResultCachedDocument
|
|
|
from wbb.modules.info import get_chat_info, get_user_info
|
|
|
from wbb.modules.music import download_youtube_audio
|
|
|
+from wbb.modules.paste import isPreviewUp
|
|
|
from wbb.utils.fetch import fetch
|
|
|
from wbb.utils.formatter import convert_seconds_to_minutes as time_convert
|
|
|
-from wbb.utils.functions import (get_http_status_code, make_carbon,
|
|
|
- test_speedtest)
|
|
|
+from wbb.utils.functions import make_carbon, test_speedtest
|
|
|
from wbb.utils.pastebin import paste
|
|
|
|
|
|
keywords_list = [
|
|
|
@@ -77,6 +90,7 @@ keywords_list = [
|
|
|
"info",
|
|
|
"chat_info",
|
|
|
"tmdb",
|
|
|
+ "pypi",
|
|
|
]
|
|
|
|
|
|
|
|
|
@@ -117,9 +131,7 @@ async def alive_function(answers):
|
|
|
ubot_state = "Dead" if not await app2.get_me() else "Alive"
|
|
|
buttons.add(
|
|
|
InlineKeyboardButton("Stats", callback_data="stats_callback"),
|
|
|
- InlineKeyboardButton(
|
|
|
- "Go Inline!", switch_inline_query_current_chat=""
|
|
|
- ),
|
|
|
+ InlineKeyboardButton("Go Inline!", switch_inline_query_current_chat=""),
|
|
|
)
|
|
|
|
|
|
msg = f"""
|
|
|
@@ -175,9 +187,7 @@ __**Translated from {result.src} to {result.dest}**__
|
|
|
),
|
|
|
InlineQueryResultArticle(
|
|
|
title=result.translatedText,
|
|
|
- input_message_content=InputTextMessageContent(
|
|
|
- result.translatedText
|
|
|
- ),
|
|
|
+ input_message_content=InputTextMessageContent(result.translatedText),
|
|
|
),
|
|
|
]
|
|
|
)
|
|
|
@@ -435,9 +445,7 @@ async def youtube_func(answers, text):
|
|
|
**Duration:** {i.duration}
|
|
|
**Uploaded:** {i.publish_time}
|
|
|
**Description:** {i.long_desc}"""
|
|
|
- description = (
|
|
|
- f"{i.views} | {i.channel} | {i.duration} | {i.publish_time}"
|
|
|
- )
|
|
|
+ description = f"{i.views} | {i.channel} | {i.duration} | {i.publish_time}"
|
|
|
answers.append(
|
|
|
InlineQueryResultArticle(
|
|
|
title=i.title,
|
|
|
@@ -488,9 +496,7 @@ async def github_user_func(answers, text):
|
|
|
result = await fetch(URL)
|
|
|
buttons = InlineKeyboard(row_width=1)
|
|
|
buttons.add(
|
|
|
- InlineKeyboardButton(
|
|
|
- text="Open On Github", url=f"https://github.com/{text}"
|
|
|
- )
|
|
|
+ InlineKeyboardButton(text="Open On Github", url=f"https://github.com/{text}")
|
|
|
)
|
|
|
caption = f"""
|
|
|
**Info Of {result['name']}**
|
|
|
@@ -529,9 +535,7 @@ async def github_repo_func(answers, text):
|
|
|
commits += developer["contributions"]
|
|
|
buttons = InlineKeyboard(row_width=1)
|
|
|
buttons.add(
|
|
|
- InlineKeyboardButton(
|
|
|
- "Open On Github", url=f"https://github.com/{text}"
|
|
|
- )
|
|
|
+ InlineKeyboardButton("Open On Github", url=f"https://github.com/{text}")
|
|
|
)
|
|
|
caption = f"""
|
|
|
**Info Of {r['full_name']}**
|
|
|
@@ -595,9 +599,7 @@ async def tg_search_func(answers, text, user_id):
|
|
|
),
|
|
|
)
|
|
|
name = (
|
|
|
- message.from_user.first_name
|
|
|
- if message.from_user.first_name
|
|
|
- else "NO NAME"
|
|
|
+ message.from_user.first_name if message.from_user.first_name else "NO NAME"
|
|
|
)
|
|
|
caption = f"""
|
|
|
**Query:** {text}
|
|
|
@@ -651,9 +653,7 @@ async def music_inline_func(answers, query):
|
|
|
"duration": f_.audio.duration if f_.audio.duration else 0,
|
|
|
}
|
|
|
)
|
|
|
- messages = list(
|
|
|
- {v["duration"]: v for v in messages_ids_and_duration}.values()
|
|
|
- )
|
|
|
+ messages = list({v["duration"]: v for v in messages_ids_and_duration}.values())
|
|
|
messages_ids = []
|
|
|
for ff_ in messages:
|
|
|
messages_ids.append(ff_["message_id"])
|
|
|
@@ -710,9 +710,7 @@ async def speedtest_init(query):
|
|
|
return answers
|
|
|
msg = "**Click The Button Below To Perform A Speedtest**"
|
|
|
button = InlineKeyboard(row_width=1)
|
|
|
- button.add(
|
|
|
- InlineKeyboardButton(text="Test", callback_data="test_speedtest")
|
|
|
- )
|
|
|
+ button.add(InlineKeyboardButton(text="Test", callback_data="test_speedtest"))
|
|
|
answers.append(
|
|
|
InlineQueryResultArticle(
|
|
|
title="Click Here",
|
|
|
@@ -762,9 +760,7 @@ async def pastebin_func(answers, link):
|
|
|
InlineQueryResultArticle(
|
|
|
title="DOCUMENT TOO BIG",
|
|
|
description="Maximum supported size is 1MB",
|
|
|
- input_message_content=InputTextMessageContent(
|
|
|
- "DOCUMENT TOO BIG"
|
|
|
- ),
|
|
|
+ input_message_content=InputTextMessageContent("DOCUMENT TOO BIG"),
|
|
|
)
|
|
|
)
|
|
|
return answers
|
|
|
@@ -774,20 +770,12 @@ async def pastebin_func(answers, link):
|
|
|
os.remove(doc)
|
|
|
link = await paste(content)
|
|
|
preview = link + "/preview.png"
|
|
|
- status_code = await get_http_status_code(preview)
|
|
|
- i = 0
|
|
|
- while status_code != 200:
|
|
|
- if i == 5:
|
|
|
- break
|
|
|
- status_code = await get_http_status_code(preview)
|
|
|
- await asyncio.sleep(0.2)
|
|
|
- i += 1
|
|
|
+ if not await isPreviewUp(preview):
|
|
|
+ return []
|
|
|
await app.send_photo(MESSAGE_DUMP_CHAT, preview) # To Pre-cache the media
|
|
|
buttons = InlineKeyboard(row_width=1)
|
|
|
buttons.add(InlineKeyboardButton(text="Paste Link", url=link))
|
|
|
- answers.append(
|
|
|
- InlineQueryResultPhoto(photo_url=preview, reply_markup=buttons)
|
|
|
- )
|
|
|
+ answers.append(InlineQueryResultPhoto(photo_url=preview, reply_markup=buttons))
|
|
|
return answers
|
|
|
|
|
|
|
|
|
@@ -803,9 +791,7 @@ async def pmpermit_func(answers, user_id, victim):
|
|
|
InlineKeyboardButton(
|
|
|
text="For promotion", callback_data="pmpermit to_scam_you a"
|
|
|
),
|
|
|
- InlineKeyboardButton(
|
|
|
- text="Approve me", callback_data="pmpermit approve_me a"
|
|
|
- ),
|
|
|
+ InlineKeyboardButton(text="Approve me", callback_data="pmpermit approve_me a"),
|
|
|
InlineKeyboardButton(
|
|
|
text="Approve", callback_data=f"pmpermit approve {victim}"
|
|
|
),
|
|
|
@@ -923,9 +909,7 @@ async def carbon_inline_func(answers, link):
|
|
|
InlineQueryResultArticle(
|
|
|
title="DOCUMENT TOO BIG",
|
|
|
description="Maximum supported size is 1MB",
|
|
|
- input_message_content=InputTextMessageContent(
|
|
|
- "DOCUMENT TOO BIG"
|
|
|
- ),
|
|
|
+ input_message_content=InputTextMessageContent("DOCUMENT TOO BIG"),
|
|
|
)
|
|
|
)
|
|
|
return answers
|
|
|
@@ -1012,9 +996,7 @@ async def tmdb_func(answers, query):
|
|
|
)
|
|
|
answers.append(
|
|
|
InlineQueryResultPhoto(
|
|
|
- photo_url=result.backdrop
|
|
|
- if result.backdrop
|
|
|
- else result.poster,
|
|
|
+ photo_url=result.backdrop if result.backdrop else result.poster,
|
|
|
caption=caption,
|
|
|
title=result.title,
|
|
|
description=f"{genre} • {result.releaseDate} • {result.rating} • {description}",
|
|
|
@@ -1022,3 +1004,55 @@ async def tmdb_func(answers, query):
|
|
|
)
|
|
|
)
|
|
|
return answers
|
|
|
+
|
|
|
+
|
|
|
+async def pypiSearchFunc(answers: list, query: str) -> list:
|
|
|
+ result = await arq.pypi(query)
|
|
|
+ if not result.ok:
|
|
|
+ answers.append(
|
|
|
+ InlineQueryResultArticle(
|
|
|
+ title="No Such Package",
|
|
|
+ description=result.result,
|
|
|
+ input_message_content=InputTextMessageContent(result.result),
|
|
|
+ )
|
|
|
+ )
|
|
|
+ return answers
|
|
|
+ result = result.result
|
|
|
+ pURLS = [f"**{key}**: {value}" for key, value in result.projectURLS.items()]
|
|
|
+ pURLS = ("\n" + "\n".join(pURLS)) if pURLS else None
|
|
|
+ caption = f"""
|
|
|
+**Name:** {result.name}
|
|
|
+**Version:** {result.version}
|
|
|
+**License:** {result.license}
|
|
|
+**Description:** {result.description}
|
|
|
+**Size:** {result.size}
|
|
|
+**Last Update:** {result.uploadTime}
|
|
|
+**Author:** {result.author}
|
|
|
+**Author's Email:** {result.authorEmail}
|
|
|
+**Requirements:** {(f'`{" | ".join(result.requirements)}`') if result.requirements else None}
|
|
|
+**Minimum Python Version:** {result.minPyVersion}
|
|
|
+**Homepage:** {result.homepage}
|
|
|
+**Bug Tracker:** {result.bugTrackURL}
|
|
|
+**Docs Url:** {result.docsURL}
|
|
|
+**Pypi Url:** {result.pypiURL}
|
|
|
+**Releases:** {result.releaseURL}
|
|
|
+**Project Urls:** ->{pURLS}
|
|
|
+"""
|
|
|
+ button = InlineKeyboard(row_width=2)
|
|
|
+ button.add(
|
|
|
+ InlineKeyboardButton(text="Open Page", url=result.pypiURL),
|
|
|
+ InlineKeyboardButton(
|
|
|
+ text="Search Again", switch_inline_query_current_chat="pypi"
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ answers.append(
|
|
|
+ InlineQueryResultArticle(
|
|
|
+ title=f"{result.name} | {result.version}",
|
|
|
+ description=result.description,
|
|
|
+ input_message_content=InputTextMessageContent(
|
|
|
+ caption, disable_web_page_preview=True
|
|
|
+ ),
|
|
|
+ reply_markup=button,
|
|
|
+ )
|
|
|
+ )
|
|
|
+ return answers
|