Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Cricket_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ async def _(client, message):
page = await resp.text()
soup = BeautifulSoup(page, "html.parser")
result = soup.find_all("description")
Sed = ""
for match in result:
Sed += match.get_text() + "\n\n"
Sed = "".join(match.get_text() + "\n\n" for match in result)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _ refactored with the following changes:

  • Use str.join() instead of for loop (use-join)

await edit_or_reply(
message,
f"<b><u>Match information Gathered Successfully</b></u>\n\n\n<code>{Sed}</code>",
Expand Down
87 changes: 48 additions & 39 deletions any_dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ async def download_file(message, url, file_name):
async with aiohttp.ClientSession() as session:
async with session.get(url) as r:
total_length = r.headers.get('content-length') or r.headers.get("Content-Length")
dl = 0
if total_length is None:
f.write(await r.read())
else:
total_length = int(total_length)
async for chunk in r.content.iter_chunked(max(int(total_length/500), (1024*1024)*2)):
dl = 0
async for chunk in r.content.iter_chunked(max(total_length // 500, (1024*1024)*2)):
Comment on lines -31 to +36
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function download_file refactored with the following changes:

dl += len(chunk)
e_ = time.time()
diff = e_ - c_
Expand All @@ -44,9 +44,23 @@ async def download_file(message, url, file_name):
estimated_total_time = elapsed_time + time_to_completion
f.write(chunk)
progress_str = "{0}{1} {2}%\n".format(
"".join(["▰" for i in range(math.floor(percentage / 10))]),
"".join(["▱" for i in range(10 - math.floor(percentage / 10))]),
round(percentage, 2))
"".join(
[
"▰"
for _ in range(math.floor(percentage / 10))
]
),
"".join(
[
"▱"
for _ in range(
10 - math.floor(percentage / 10)
)
]
),
round(percentage, 2),
)

r_ = f"<b><u>Downloading This File</b></u> \n<b>File :</b> <code>{file_name}</code> \n<b>File Size :</b> <code>{humanbytes(total_length)}</code> \n<b>Downloaded :</b> <code>{humanbytes(dl)}</code> \n{progress_str} \n\n<b>Speed :</b> <code>{humanbytes(round(speed))}/ps</code> \n<b>ETA :</b> <code>{time_formatter(estimated_total_time)}</code>"
try:
await message.edit(r_)
Expand Down Expand Up @@ -85,9 +99,7 @@ async def upload_file(client, reply_message, message, file_path, caption):
async def send_file(client, r_msg, file, capt, e_msg):
c_time = time.time()
file_name = os.path.basename(file)
send_as_thumb = False
if os.path.exists("./main_startup/Cache/thumb.jpg"):
send_as_thumb = True
send_as_thumb = bool(os.path.exists("./main_startup/Cache/thumb.jpg"))
Comment on lines -88 to +102
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function send_file refactored with the following changes:

if file.endswith(image_ext):
await r_msg.reply_video(
file,
Expand Down Expand Up @@ -157,24 +169,23 @@ async def send_file(client, r_msg, file, capt, e_msg):
progress=progress,
progress_args=(e_msg, c_time, f"`Uploading {file_name}!`", file_name),
)
elif send_as_thumb:
await r_msg.reply_document(
file,
quote=True,
thumb="./main_startup/Cache/thumb.jpg",
caption=capt,
progress=progress,
progress_args=(e_msg, c_time, f"`Uploading {file_name}!`", file_name),
)
else:
if send_as_thumb:
await r_msg.reply_document(
file,
quote=True,
thumb="./main_startup/Cache/thumb.jpg",
caption=capt,
progress=progress,
progress_args=(e_msg, c_time, f"`Uploading {file_name}!`", file_name),
)
else:
await r_msg.reply_document(
file,
quote=True,
caption=capt,
progress=progress,
progress_args=(e_msg, c_time, f"`Uploading {file_name}!`", file_name),
)
await r_msg.reply_document(
file,
quote=True,
caption=capt,
progress=progress,
progress_args=(e_msg, c_time, f"`Uploading {file_name}!`", file_name),
)

def file_list(path, lisT):
pathlib.Path(path)
Expand Down Expand Up @@ -203,8 +214,8 @@ async def download_(client, message):
file_url, file_name = await dl_client.gdrive(url)
except BaseException as e:
return await s.edit(f"**Failed To GET Direct Link ::** `{e}`")
if file_url == None:
return await s.edit(f"**Failed To GET Direct Link**")
if file_url is None:
return await s.edit("**Failed To GET Direct Link**")
Comment on lines -206 to +218
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function download_ refactored with the following changes:

file = await download_file(s, file_url, file_name)
caption = f"<b><u>File Downloaded & Uploaded</b></u> \n<b>File Name :</b> <code>{file_name}</code>"
await upload_file(client, msg, s, file, caption)
Expand All @@ -218,8 +229,8 @@ async def download_(client, message):
file_url, file_name, file_size, file_upload_date, caption_, scan_result = await dl_client.media_fire_dl(url)
except BaseException as e:
return await s.edit(f"**Failed To GET Direct Link ::** `{e}`")
if file_url == None:
return await s.edit(f"**Failed To GET Direct Link**")
if file_url is None:
return await s.edit("**Failed To GET Direct Link**")
file = await download_file(s, file_url, file_name)
caption = f"<b><u>File Downloaded & Uploaded</b></u> \n<b>File Name :</b> <code>{file_name}</code> \n<b>File Size :</b> <code>{file_size}</code> \n<b>File Upload Date :</b> <code>{file_upload_date}</code> \n<b>File Scan Result :</b> <code>{scan_result}</code> \n<code>{caption_}</code>"
await upload_file(client, msg, s, file, caption)
Expand All @@ -235,8 +246,8 @@ async def download_(client, message):
file_url, file_name, file_size = await dl_client.mega_dl(link)
except BaseException as e:
return await s.edit(f"**Failed To GET Direct Link ::** `{e}`")
if file_url == None:
return await s.edit(f"**Failed To GET Direct Link**")
if file_url is None:
return await s.edit("**Failed To GET Direct Link**")
file = await download_file(s, file_url, file_name)
file_size = humanbytes(file_size)
caption = f"<b><u>File Downloaded & Uploaded</b></u> \n<b>File Name :</b> <code>{file_name}</code> \n<b>File Size :</b> <code>{file_size}</code>"
Expand All @@ -251,12 +262,9 @@ async def download_(client, message):
file_url, file_size, file_name = await dl_client.anon_files_dl(link)
except BaseException as e:
return await s.edit(f"**Failed To GET Direct Link ::** `{e}`")
if file_url == None:
return await s.edit(f"**Failed To GET Direct Link**")
if file_url is None:
return await s.edit("**Failed To GET Direct Link**")
file = await download_file(s, file_url, file_name)
caption = f"<b><u>File Downloaded & Uploaded</b></u> \n<b>File Name :</b> <code>{file_name}</code> \n<b>File Size :</b> <code>{file_size}</code>"
await upload_file(client, msg, s, file, caption)
return os.remove(file)
else:
url_ = url.split('|')
if len(url_) != 2:
Expand All @@ -268,7 +276,8 @@ async def download_(client, message):
except BaseException as e:
return await s.edit(f"**Failed To Download ::** `{e}`")
file_size = humanbytes(os.stat(file).st_size)
caption = f"<b><u>File Downloaded & Uploaded</b></u> \n<b>File Name :</b> <code>{file_name}</code> \n<b>File Size :</b> <code>{file_size}</code>"
await upload_file(client, msg, s, file, caption)
return os.remove(file)

caption = f"<b><u>File Downloaded & Uploaded</b></u> \n<b>File Name :</b> <code>{file_name}</code> \n<b>File Size :</b> <code>{file_size}</code>"
await upload_file(client, msg, s, file, caption)
return os.remove(file)

4 changes: 2 additions & 2 deletions carbon.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def make_carbon(code, driver, lang="auto"):
type_ = '//*[@id="__next"]/main/div[2]/div[2]/div[1]/div[1]/div/span[2]'
em = "export-menu"
png_xpath = '//*[@id="export-png"]'
four_x_path = '//*[@id="__next"]/main/div[2]/div[2]/div[1]/div[3]/div[4]/div[3]/div[2]/div[3]/div/button[3]'
four_x_path = '//*[@id="__next"]/main/div[2]/div[2]/div[1]/div[3]/div[4]/div[3]/div[2]/div[3]/div/button[3]'
color_used_xpath = '/html/body/div[1]/main/div[2]/div[2]/div[1]/div[1]/div/span[2]/input'
random_int = random.randint(1, 29)
value_ = "downshift-0-item-" + str(random_int)
value_ = f"downshift-0-item-{str(random_int)}"
Comment on lines -38 to +41
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function make_carbon refactored with the following changes:

wait = WebDriverWait(driver, 20)
wait.until(EC.visibility_of_element_located((By.XPATH, type_))).click()
wait.until(EC.visibility_of_element_located((By.ID, value_))).click()
Expand Down
12 changes: 8 additions & 4 deletions cc_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def namso_gen(bin, no_of_result=15):
button_xpath = '/html/body/div/div/div/main/div/div/div[3]/div[1]/form/div[5]/button'
w.until(EC.visibility_of_element_located((By.XPATH, bin_xpath))).send_keys(bin)
elem3 = w.until(EC.visibility_of_element_located((By.XPATH, no_of_r_xpath)))
for i in range(2):
for _ in range(2):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function namso_gen refactored with the following changes:

elem3.send_keys(Keys.BACKSPACE)
elem3 = w.until(EC.visibility_of_element_located((By.XPATH, no_of_r_xpath)))
elem3.send_keys(no_of_result)
Expand Down Expand Up @@ -97,9 +97,13 @@ async def ns_gen(client, message):
await msg.edit(t, parse_mode="md")

def stark_finder(to_find, from_find):
if re.search(r"( |^|[^\w])" + re.escape(to_find) + r"( |$|[^\w])", from_find, flags=re.IGNORECASE):
return True
return False
return bool(
re.search(
f"( |^|[^\\w]){re.escape(to_find)}( |$|[^\\w])",
from_find,
flags=re.IGNORECASE,
)
)
Comment on lines -100 to +106
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function stark_finder refactored with the following changes:


my_code = {
400: "『! Invalid Key !』",
Expand Down
12 changes: 7 additions & 5 deletions collage.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

async def create_s_collage(file_path, filename, width, stark_h):
"""Create Image Collage"""
img_stark = [filepath for filepath in pathlib.Path(file_path).glob("**/*")]
img_stark = list(pathlib.Path(file_path).glob("**/*"))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function create_s_collage refactored with the following changes:

margin_size = 2
while True:
img_stark_list = list(img_stark)
Expand All @@ -45,10 +45,12 @@ async def create_s_collage(file_path, filename, width, stark_h):
stark_h -= 10
else:
break
out_lol_h = 0
for meisnub, sedlife in ujwal_liness:
if sedlife:
out_lol_h += int(stark_h / meisnub) + margin_size
out_lol_h = sum(
int(stark_h / meisnub) + margin_size
for meisnub, sedlife in ujwal_liness
if sedlife
)

if not out_lol_h:
return None
final_image = Image.new('RGB', (width, int(out_lol_h)), (35, 35, 35))
Expand Down
40 changes: 20 additions & 20 deletions fban.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,32 +179,32 @@ async def fetch_all_fed(client, message):
pass
await asyncio.sleep(7)
sed = (await client.get_history("@MissRose_bot", 1))[0]
if sed.media:
fed_file = await sed.download()
file = open(fed_file, "r")
lines = file.readlines()
for line in lines:
try:
fed_list.append(line[:36])
except BaseException:
pass
os.remove(fed_file)
else:
if not sed.media:
return None
fed_file = await sed.download()
file = open(fed_file, "r")
lines = file.readlines()
for line in lines:
try:
fed_list.append(line[:36])
except BaseException:
pass
os.remove(fed_file)
else:
X = ok.text
lol = X.splitlines()
if "you are the owner" in X.lower():
for lo in lol:
if "you are the owner" not in lo.lower():
if "you are admin" not in lo.lower():
if lo[:36] != "":
if not lo.startswith("-"):
fed_list.append(lo[:36])
else:
fed_list.append(lo[2:38])
if (
"you are the owner" not in lo.lower()
and "you are admin" not in lo.lower()
and lo[:36] != ""
):
if not lo.startswith("-"):
fed_list.append(lo[:36])
else:
fed_list.append(lo[2:38])
else:
Y = X[44:].splitlines()
for lol in Y:
fed_list.append(lol[2:38])
fed_list.extend(lol[2:38] for lol in Y)
Comment on lines -182 to +209
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function fetch_all_fed refactored with the following changes:

return fed_list
2 changes: 1 addition & 1 deletion github_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ async def git(client, message):
if qw.get("created_at"):
txt += f'<b>Created At :</b> <code>{qw.get("created_at")}</code>'
if qw.get("archived") == True:
txt += f"<b>This Project is Archived</b>"
txt += "<b>This Project is Archived</b>"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function git refactored with the following changes:

await pablo.edit(txt, disable_web_page_preview=True)
9 changes: 3 additions & 6 deletions harem.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ async def remove_nsfw(client, message):
async def is_harem_enabled(f, client, message):
if Config.ENABLE_WAIFU_FOR_ALL_CHATS:
return bool(True)
if await is_chat_in_db(int(message.chat.id)):
return bool(True)
else:
return bool(False)
return bool(True) if await is_chat_in_db(int(message.chat.id)) else bool(False)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function is_harem_enabled refactored with the following changes:


async def harem_event(f, client, message):
if not message:
Expand All @@ -117,11 +114,11 @@ def get_data(img):
harem_event = filters.create(func=harem_event, name="harem_event")
is_harem_enabled = filters.create(func=is_harem_enabled, name="is_harem_enabled")

@listen(filters.user([int(792028928)]) & ~filters.edited & is_harem_enabled & harem_event & filters.group)
@listen(filters.user([792028928]) & ~filters.edited & is_harem_enabled & harem_event & filters.group)
async def harem_catcher(client, message):
img = await message.download()
fetchUrl = await get_data(img)
match = await ParseSauce(fetchUrl + "&preferences?hl=en&fg=1#languages")
match = await ParseSauce(f'{fetchUrl}&preferences?hl=en&fg=1#languages')
Comment on lines -120 to +121
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function harem_catcher refactored with the following changes:

guessp = match["best_guess"]
if not guessp:
return logging.info("(Waifu Catch Failed.) \nERROR : 404: Waifu Not Found.")
Expand Down
6 changes: 2 additions & 4 deletions helper_files/dl_.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ def gdrive(self, url):
url = f'{drive}/uc?export=download&id={file_id}'
download = requests.get(url, stream=True, allow_redirects=False)
cookies = download.cookies
dl_url = None
if download.headers:
dl_url = download.headers.get("location")
dl_url = download.headers.get("location") if download.headers else None
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AnyDL.gdrive refactored with the following changes:

if not dl_url:
page = BeautifulSoup(download.content, 'lxml')
export = drive + page.find('a', {'id': 'uc-download-url'}).get('href')
Expand All @@ -48,7 +46,7 @@ def gdrive(self, url):

async def mega_dl(self, url):
path = parse_url(url).split('!')
if path == None:
if path is None:
Comment on lines -51 to +49
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AnyDL.mega_dl refactored with the following changes:

return None, None, None
file_handle = path[0]
file_key = path[1]
Expand Down
Loading