Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored dev branch #127

Merged
merged 2 commits into from Aug 11, 2021
Merged

Sourcery refactored dev branch #127

merged 2 commits into from Aug 11, 2021

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Aug 11, 2021

Branch dev refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the dev branch, then run:

git fetch origin sourcery/dev
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from New-dev0 August 11, 2021 16:19
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Due to GitHub API limits, only the first 60 comments can be shown.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Message that will be displayed on users first pull request

Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Due to GitHub API limits, only the first 60 comments can be shown.

button = [Button.inline("« Bᴀᴄᴋ", data=f"{name}")]
return button
return [Button.inline("« Bᴀᴄᴋ", data=f"{name}")]
Copy link
Author

Choose a reason for hiding this comment

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

Function get_back_button refactored with the following changes:

Comment on lines -44 to +48
else:
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("apiset"),
)
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("apiset"),
)
Copy link
Author

Choose a reason for hiding this comment

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

Function rmbgapi refactored with the following changes:

Comment on lines -69 to +72
else:
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("apiset"),
)
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("apiset"),
)
Copy link
Author

Choose a reason for hiding this comment

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

Function rmbgapi refactored with the following changes:

Comment on lines -94 to +96
else:
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("apiset"),
)
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("apiset"),
)
Copy link
Author

Choose a reason for hiding this comment

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

Function rmbgapi refactored with the following changes:

Comment on lines 61 to 64
thumb = ""
for m in choices(sorted(glob("resources/extras/*.jpg"))):
thumb += m
thumb = "".join(choices(sorted(glob("resources/extras/*.jpg"))))
await eve.answer("Sending...")
if name.startswith("def"):
plug_name = name.replace(f"def_plugin_", "")
plug_name = name.replace('def_plugin_', "")
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 refactored with the following changes:

Comment on lines -866 to +861
else:
if len(themssg) > 4090:
return await conv.send_message(
"Message too long!\nGive a shorter message please!!",
buttons=get_back_button("pmcstm"),
)
await setit(event, var, themssg)
await conv.send_message(
"{} changed to {}\n\nAfter Setting All Things Do restart".format(
name,
themssg,
),
if len(themssg) > 4090:
return await conv.send_message(
"Message too long!\nGive a shorter message please!!",
buttons=get_back_button("pmcstm"),
)
await setit(event, var, themssg)
await conv.send_message(
"{} changed to {}\n\nAfter Setting All Things Do restart".format(
name,
themssg,
),
buttons=get_back_button("pmcstm"),
)
Copy link
Author

Choose a reason for hiding this comment

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

Function name refactored with the following changes:

Comment on lines -936 to +918
and not response.text == ""
and response.text != ""
Copy link
Author

Choose a reason for hiding this comment

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

Function media refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

Comment on lines 989 to 971
f"Done!! AUTOAPPROVE Started!!",
'Done!! AUTOAPPROVE Started!!',
Copy link
Author

Choose a reason for hiding this comment

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

Function apon refactored with the following changes:

Comment on lines 1029 to 1011
f"Done!! PMLOGGER Started!!",
'Done!! PMLOGGER Started!!',
Copy link
Author

Choose a reason for hiding this comment

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

Function pmlog refactored with the following changes:

Comment on lines 1070 to 1052
f"Done! PMPermit has been turned on!!",
'Done! PMPermit has been turned on!!',
Copy link
Author

Choose a reason for hiding this comment

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

Function pmonn refactored with the following changes:

Comment on lines 1081 to 1063
f"Done! PMPermit has been turned off!!",
'Done! PMPermit has been turned off!!',
Copy link
Author

Choose a reason for hiding this comment

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

Function pmofff refactored with the following changes:

Comment on lines 1090 to 1072
f"From This Feature U can chat with ppls Via ur Assistant Bot.\n[More info](https://t.me/UltroidUpdates/2)",
'From This Feature U can chat with ppls Via ur Assistant Bot.\n[More info](https://t.me/UltroidUpdates/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 chbot refactored with the following changes:

Comment on lines -1120 to +1109
else:
await setit(event, var, themssg)
await conv.send_message(
"{} changed to {}".format(
name,
themssg,
),
buttons=get_back_button("chatbot"),
)
await setit(event, var, themssg)
await conv.send_message(
"{} changed to {}".format(
name,
themssg,
),
buttons=get_back_button("chatbot"),
)
Copy link
Author

Choose a reason for hiding this comment

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

Function name refactored with the following changes:

Comment on lines 1157 to 1138
f"From This Feature U can play songs in group voice chat\n\n[moreinfo](https://t.me/UltroidUpdates/4)",
'From This Feature U can play songs in group voice chat\n\n[moreinfo](https://t.me/UltroidUpdates/4)',
Copy link
Author

Choose a reason for hiding this comment

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

Function vcb refactored with the following changes:

Comment on lines -1185 to +1173
else:
await setit(event, var, themssg)
await conv.send_message(
"{} changed to {}\n\nAfter Setting All Things Do restart".format(
name,
themssg,
),
buttons=get_back_button("vcb"),
)
await setit(event, var, themssg)
await conv.send_message(
"{} changed to {}\n\nAfter Setting All Things Do restart".format(
name,
themssg,
),
buttons=get_back_button("vcb"),
)
Copy link
Author

Choose a reason for hiding this comment

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

Function name refactored with the following changes:

await o.answer(RES, switch_pm=f"👥 ULTROID PORTAL", switch_pm_param="start")
await o.answer(RES, switch_pm='👥 ULTROID PORTAL', switch_pm_param="start")
Copy link
Author

Choose a reason for hiding this comment

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

Function inline_alive refactored with the following changes:

Comment on lines 184 to 188
changelog_str = changelog + f"\n\nClick the below button to update!"
changelog_str = changelog + '\n\nClick the below button to update!'
if len(changelog_str) > 1024:
await event.edit(get_string("upd_4"))
file = open(f"ultroid_updates.txt", "w+")
file.write(tl_chnglog)
file.close()
with open('ultroid_updates.txt', "w+") as file:
file.write(tl_chnglog)
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:

Comment on lines -531 to +533
if emoji:
multi = emoji
else:
multi = "✘"
helpable_plugins = []
multi = emoji or "✘"
global upage
upage = page_number
for p in loaded_plugins:
helpable_plugins.append(p)
helpable_plugins = [p for p in loaded_plugins]
Copy link
Author

Choose a reason for hiding this comment

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

Function page_num refactored with the following changes:

plugins/_wspr.py Outdated
sur = e.builder.article(
title="Type ur msg",
text=f"You Didn't Type Your Msg",
)
sur = e.builder.article(title="Type ur msg", text="You Didn't Type Your Msg")
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:

return await eor(msg, f"**ERROR:**`{str(e)}`")
return await eor(msg, f'**ERROR:**`{e}`')
Copy link
Author

Choose a reason for hiding this comment

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

Function pin refactored with the following changes:

Comment on lines 299 to 306
return await xx.edit(f"**ERROR:**\n`{str(e)}`")
return await xx.edit(f'**ERROR:**\n`{e}`')
elif ch == "all":
try:
await ult.client.unpin_message(ult.chat_id)
except BadRequestError:
return await xx.edit("`Hmm.. Guess I have no rights here!`")
except Exception as e:
return await xx.edit(f"**ERROR:**`{str(e)}`")
return await xx.edit(f'**ERROR:**`{e}`')
Copy link
Author

Choose a reason for hiding this comment

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

Function unp refactored with the following changes:

count = count + 1
count += 1
Copy link
Author

Choose a reason for hiding this comment

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

Function fastpurger refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

count = count + 1
count += 1
Copy link
Author

Choose a reason for hiding this comment

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

Function fastpurgerme refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

Comment on lines -412 to +423
if e.reply_to_msg_id:
name = (await e.get_reply_message()).sender
try:
await e.client(DeleteUserHistoryRequest(e.chat_id, name.id))
await eod(e, f"Successfully Purged All Messages from {name.first_name}")
except Exception as er:
return await eod(xx, str(er))
else:
if not e.reply_to_msg_id:
return await eod(
xx,
"`Reply to someone's msg to delete.`",
)

name = (await e.get_reply_message()).sender
try:
await e.client(DeleteUserHistoryRequest(e.chat_id, name.id))
await eod(e, f"Successfully Purged All Messages from {name.first_name}")
except Exception as er:
return await eod(xx, str(er))
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:

Comment on lines -47 to +52
if event.is_private:
if Redis("PMSETTING") == "True":
if not is_approved(event.chat_id):
return
if (
event.is_private
and Redis("PMSETTING") == "True"
and not is_approved(event.chat_id)
):
return
Copy link
Author

Choose a reason for hiding this comment

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

Function set_not_afk refactored with the following changes:

Comment on lines -184 to +185
a = open(b)
code = a.read()
a.close()
with open(b) as a:
code = a.read()
Copy link
Author

Choose a reason for hiding this comment

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

Function crbn refactored with the following changes:

a = open(b)
code = a.read()
a.close()
with open(b) as a:
code = a.read()
Copy link
Author

Choose a reason for hiding this comment

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

Function crbn refactored with the following changes:

if not udB.get("AUTOPOST") == "True":
if udB.get("AUTOPOST") != "True":
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:

  • Simplify logical expression using De Morgan identities (de-morgan)

Comment on lines -102 to +111
elif type_of_group == "g" or type_of_group == "c":
elif type_of_group in ["g", "c"]:
try:
r = await e.client(
CreateChannelRequest(
title=group_name,
about="Join @TeamUltroid",
megagroup=False if type_of_group == "c" else True,
),
megagroup=type_of_group != "c",
)
)

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:

Comment on lines 47 to 177
time_diff = time.time() - int(d_time)
speed = round(elapse / time_diff, 2)
if int(speed) != 0:
some_eta = ((int(total_frames) - elapse) / speed) * 1000
text = f"`Compressing {file_name} at {crf} CRF.\n`"
progress_str = "`[{0}{1}] {2}%\n\n`".format(
"".join("●" for i in range(math.floor(per / 5))),
"".join("" for i in range(20 - math.floor(per / 5))),
round(per, 2),
)
]
await e.client.send_file(
e.chat_id,
mmmm,
thumb="resources/extras/ultroid.jpg",
caption=caption,
attributes=attributes,
force_document=False,
reply_to=e.reply_to_msg_id,
)
else:
await e.client.send_file(
e.chat_id,
mmmm,
thumb="resources/extras/ultroid.jpg",
caption=caption,
force_document=True,
reply_to=e.reply_to_msg_id,

e_size = (
humanbytes(size) + " of ~" + humanbytes((size / per) * 100)
)
eta = "~" + time_formatter(some_eta)
try:
await xxx.edit(
text
+ progress_str
+ "`"
+ e_size
+ "`"
+ "\n\n`"
+ eta
+ "`"
)
except MessageNotModifiedError:
pass
os.remove(file.name)
c_size = os.path.getsize(out)
f_time = time.time()
difff = time_formatter((f_time - d_time) * 1000)
await xxx.edit(
f"`Compressed {humanbytes(o_size)} to {humanbytes(c_size)} in {difff}\nTrying to Upload...`"
)
differ = 100 - ((c_size / o_size) * 100)
caption = f"**Original Size: **`{humanbytes(o_size)}`\n"
caption += f"**Compressed Size: **`{humanbytes(c_size)}`\n"
caption += f"**Compression Ratio: **`{differ:.2f}%`\n"
caption += f"\n**Time Taken To Compress: **`{difff}`"
mmmm = await uploader(
out,
out,
f_time,
xxx,
"Uploading " + out + "...",
)
if to_stream:
metadata = extractMetadata(createParser(out))
duration = metadata.get("duration").seconds
hi, _ = await bash(f'mediainfo "{out}" | grep "Height"')
wi, _ = await bash(f'mediainfo "{out}" | grep "Width"')
height = int(hi.split(":")[1].split("pixels")[0].replace(" ", ""))
width = int(wi.split(":")[1].split("pixels")[0].replace(" ", ""))
attributes = [
DocumentAttributeVideo(
duration=duration, w=width, h=height, supports_streaming=True
)
await xxx.delete()
os.remove(out)
]
await e.client.send_file(
e.chat_id,
mmmm,
thumb="resources/extras/ultroid.jpg",
caption=caption,
attributes=attributes,
force_document=False,
reply_to=e.reply_to_msg_id,
)
else:
await eod(e, "`Reply To Video File Only`")
await e.client.send_file(
e.chat_id,
mmmm,
thumb="resources/extras/ultroid.jpg",
caption=caption,
force_document=True,
reply_to=e.reply_to_msg_id,
)
await xxx.delete()
os.remove(out)
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:

Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Due to GitHub API limits, only the first 60 comments can be shown.

button = [Button.inline("« Bᴀᴄᴋ", data=f"{name}")]
return button
return [Button.inline("« Bᴀᴄᴋ", data=f"{name}")]
Copy link
Author

Choose a reason for hiding this comment

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

Function get_back_button refactored with the following changes:

Comment on lines -44 to +48
else:
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("apiset"),
)
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("apiset"),
)
Copy link
Author

Choose a reason for hiding this comment

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

Function rmbgapi refactored with the following changes:

Comment on lines -69 to +72
else:
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("apiset"),
)
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("apiset"),
)
Copy link
Author

Choose a reason for hiding this comment

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

Function rmbgapi refactored with the following changes:

Comment on lines -94 to +96
else:
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("apiset"),
)
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("apiset"),
)
Copy link
Author

Choose a reason for hiding this comment

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

Function rmbgapi refactored with the following changes:

Comment on lines 61 to 64
thumb = ""
for m in choices(sorted(glob("resources/extras/*.jpg"))):
thumb += m
thumb = "".join(choices(sorted(glob("resources/extras/*.jpg"))))
await eve.answer("Sending...")
if name.startswith("def"):
plug_name = name.replace(f"def_plugin_", "")
plug_name = name.replace('def_plugin_', "")
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 refactored with the following changes:

Comment on lines -866 to +861
else:
if len(themssg) > 4090:
return await conv.send_message(
"Message too long!\nGive a shorter message please!!",
buttons=get_back_button("pmcstm"),
)
await setit(event, var, themssg)
await conv.send_message(
"{} changed to {}\n\nAfter Setting All Things Do restart".format(
name,
themssg,
),
if len(themssg) > 4090:
return await conv.send_message(
"Message too long!\nGive a shorter message please!!",
buttons=get_back_button("pmcstm"),
)
await setit(event, var, themssg)
await conv.send_message(
"{} changed to {}\n\nAfter Setting All Things Do restart".format(
name,
themssg,
),
buttons=get_back_button("pmcstm"),
)
Copy link
Author

Choose a reason for hiding this comment

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

Function name refactored with the following changes:

Comment on lines -936 to +918
and not response.text == ""
and response.text != ""
Copy link
Author

Choose a reason for hiding this comment

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

Function media refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

Comment on lines 989 to 971
f"Done!! AUTOAPPROVE Started!!",
'Done!! AUTOAPPROVE Started!!',
Copy link
Author

Choose a reason for hiding this comment

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

Function apon refactored with the following changes:

Comment on lines 1029 to 1011
f"Done!! PMLOGGER Started!!",
'Done!! PMLOGGER Started!!',
Copy link
Author

Choose a reason for hiding this comment

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

Function pmlog refactored with the following changes:

Comment on lines 1070 to 1052
f"Done! PMPermit has been turned on!!",
'Done! PMPermit has been turned on!!',
Copy link
Author

Choose a reason for hiding this comment

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

Function pmonn refactored with the following changes:

Comment on lines 1081 to 1063
f"Done! PMPermit has been turned off!!",
'Done! PMPermit has been turned off!!',
Copy link
Author

Choose a reason for hiding this comment

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

Function pmofff refactored with the following changes:

Comment on lines 1090 to 1072
f"From This Feature U can chat with ppls Via ur Assistant Bot.\n[More info](https://t.me/UltroidUpdates/2)",
'From This Feature U can chat with ppls Via ur Assistant Bot.\n[More info](https://t.me/UltroidUpdates/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 chbot refactored with the following changes:

Comment on lines -1120 to +1109
else:
await setit(event, var, themssg)
await conv.send_message(
"{} changed to {}".format(
name,
themssg,
),
buttons=get_back_button("chatbot"),
)
await setit(event, var, themssg)
await conv.send_message(
"{} changed to {}".format(
name,
themssg,
),
buttons=get_back_button("chatbot"),
)
Copy link
Author

Choose a reason for hiding this comment

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

Function name refactored with the following changes:

Comment on lines 1157 to 1138
f"From This Feature U can play songs in group voice chat\n\n[moreinfo](https://t.me/UltroidUpdates/4)",
'From This Feature U can play songs in group voice chat\n\n[moreinfo](https://t.me/UltroidUpdates/4)',
Copy link
Author

Choose a reason for hiding this comment

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

Function vcb refactored with the following changes:

Comment on lines -1185 to +1173
else:
await setit(event, var, themssg)
await conv.send_message(
"{} changed to {}\n\nAfter Setting All Things Do restart".format(
name,
themssg,
),
buttons=get_back_button("vcb"),
)
await setit(event, var, themssg)
await conv.send_message(
"{} changed to {}\n\nAfter Setting All Things Do restart".format(
name,
themssg,
),
buttons=get_back_button("vcb"),
)
Copy link
Author

Choose a reason for hiding this comment

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

Function name refactored with the following changes:

await o.answer(RES, switch_pm=f"👥 ULTROID PORTAL", switch_pm_param="start")
await o.answer(RES, switch_pm='👥 ULTROID PORTAL', switch_pm_param="start")
Copy link
Author

Choose a reason for hiding this comment

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

Function inline_alive refactored with the following changes:

Comment on lines 184 to 188
changelog_str = changelog + f"\n\nClick the below button to update!"
changelog_str = changelog + '\n\nClick the below button to update!'
if len(changelog_str) > 1024:
await event.edit(get_string("upd_4"))
file = open(f"ultroid_updates.txt", "w+")
file.write(tl_chnglog)
file.close()
with open('ultroid_updates.txt', "w+") as file:
file.write(tl_chnglog)
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:

Comment on lines -531 to +533
if emoji:
multi = emoji
else:
multi = "✘"
helpable_plugins = []
multi = emoji or "✘"
global upage
upage = page_number
for p in loaded_plugins:
helpable_plugins.append(p)
helpable_plugins = [p for p in loaded_plugins]
Copy link
Author

Choose a reason for hiding this comment

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

Function page_num refactored with the following changes:

plugins/_wspr.py Outdated
sur = e.builder.article(
title="Type ur msg",
text=f"You Didn't Type Your Msg",
)
sur = e.builder.article(title="Type ur msg", text="You Didn't Type Your Msg")
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:

return await eor(msg, f"**ERROR:**`{str(e)}`")
return await eor(msg, f'**ERROR:**`{e}`')
Copy link
Author

Choose a reason for hiding this comment

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

Function pin refactored with the following changes:

Comment on lines 299 to 306
return await xx.edit(f"**ERROR:**\n`{str(e)}`")
return await xx.edit(f'**ERROR:**\n`{e}`')
elif ch == "all":
try:
await ult.client.unpin_message(ult.chat_id)
except BadRequestError:
return await xx.edit("`Hmm.. Guess I have no rights here!`")
except Exception as e:
return await xx.edit(f"**ERROR:**`{str(e)}`")
return await xx.edit(f'**ERROR:**`{e}`')
Copy link
Author

Choose a reason for hiding this comment

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

Function unp refactored with the following changes:

count = count + 1
count += 1
Copy link
Author

Choose a reason for hiding this comment

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

Function fastpurger refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

count = count + 1
count += 1
Copy link
Author

Choose a reason for hiding this comment

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

Function fastpurgerme refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

Comment on lines -412 to +423
if e.reply_to_msg_id:
name = (await e.get_reply_message()).sender
try:
await e.client(DeleteUserHistoryRequest(e.chat_id, name.id))
await eod(e, f"Successfully Purged All Messages from {name.first_name}")
except Exception as er:
return await eod(xx, str(er))
else:
if not e.reply_to_msg_id:
return await eod(
xx,
"`Reply to someone's msg to delete.`",
)

name = (await e.get_reply_message()).sender
try:
await e.client(DeleteUserHistoryRequest(e.chat_id, name.id))
await eod(e, f"Successfully Purged All Messages from {name.first_name}")
except Exception as er:
return await eod(xx, str(er))
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:

Comment on lines -47 to +52
if event.is_private:
if Redis("PMSETTING") == "True":
if not is_approved(event.chat_id):
return
if (
event.is_private
and Redis("PMSETTING") == "True"
and not is_approved(event.chat_id)
):
return
Copy link
Author

Choose a reason for hiding this comment

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

Function set_not_afk refactored with the following changes:

Comment on lines -184 to +185
a = open(b)
code = a.read()
a.close()
with open(b) as a:
code = a.read()
Copy link
Author

Choose a reason for hiding this comment

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

Function crbn refactored with the following changes:

a = open(b)
code = a.read()
a.close()
with open(b) as a:
code = a.read()
Copy link
Author

Choose a reason for hiding this comment

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

Function crbn refactored with the following changes:

if not udB.get("AUTOPOST") == "True":
if udB.get("AUTOPOST") != "True":
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:

  • Simplify logical expression using De Morgan identities (de-morgan)

Comment on lines -102 to +111
elif type_of_group == "g" or type_of_group == "c":
elif type_of_group in ["g", "c"]:
try:
r = await e.client(
CreateChannelRequest(
title=group_name,
about="Join @TeamUltroid",
megagroup=False if type_of_group == "c" else True,
),
megagroup=type_of_group != "c",
)
)

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:

Comment on lines 47 to 177
time_diff = time.time() - int(d_time)
speed = round(elapse / time_diff, 2)
if int(speed) != 0:
some_eta = ((int(total_frames) - elapse) / speed) * 1000
text = f"`Compressing {file_name} at {crf} CRF.\n`"
progress_str = "`[{0}{1}] {2}%\n\n`".format(
"".join("●" for i in range(math.floor(per / 5))),
"".join("" for i in range(20 - math.floor(per / 5))),
round(per, 2),
)
]
await e.client.send_file(
e.chat_id,
mmmm,
thumb="resources/extras/ultroid.jpg",
caption=caption,
attributes=attributes,
force_document=False,
reply_to=e.reply_to_msg_id,
)
else:
await e.client.send_file(
e.chat_id,
mmmm,
thumb="resources/extras/ultroid.jpg",
caption=caption,
force_document=True,
reply_to=e.reply_to_msg_id,

e_size = (
humanbytes(size) + " of ~" + humanbytes((size / per) * 100)
)
eta = "~" + time_formatter(some_eta)
try:
await xxx.edit(
text
+ progress_str
+ "`"
+ e_size
+ "`"
+ "\n\n`"
+ eta
+ "`"
)
except MessageNotModifiedError:
pass
os.remove(file.name)
c_size = os.path.getsize(out)
f_time = time.time()
difff = time_formatter((f_time - d_time) * 1000)
await xxx.edit(
f"`Compressed {humanbytes(o_size)} to {humanbytes(c_size)} in {difff}\nTrying to Upload...`"
)
differ = 100 - ((c_size / o_size) * 100)
caption = f"**Original Size: **`{humanbytes(o_size)}`\n"
caption += f"**Compressed Size: **`{humanbytes(c_size)}`\n"
caption += f"**Compression Ratio: **`{differ:.2f}%`\n"
caption += f"\n**Time Taken To Compress: **`{difff}`"
mmmm = await uploader(
out,
out,
f_time,
xxx,
"Uploading " + out + "...",
)
if to_stream:
metadata = extractMetadata(createParser(out))
duration = metadata.get("duration").seconds
hi, _ = await bash(f'mediainfo "{out}" | grep "Height"')
wi, _ = await bash(f'mediainfo "{out}" | grep "Width"')
height = int(hi.split(":")[1].split("pixels")[0].replace(" ", ""))
width = int(wi.split(":")[1].split("pixels")[0].replace(" ", ""))
attributes = [
DocumentAttributeVideo(
duration=duration, w=width, h=height, supports_streaming=True
)
await xxx.delete()
os.remove(out)
]
await e.client.send_file(
e.chat_id,
mmmm,
thumb="resources/extras/ultroid.jpg",
caption=caption,
attributes=attributes,
force_document=False,
reply_to=e.reply_to_msg_id,
)
else:
await eod(e, "`Reply To Video File Only`")
await e.client.send_file(
e.chat_id,
mmmm,
thumb="resources/extras/ultroid.jpg",
caption=caption,
force_document=True,
reply_to=e.reply_to_msg_id,
)
await xxx.delete()
os.remove(out)
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:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Aug 11, 2021

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 1.19%.

Quality metrics Before After Change
Complexity 20.60 😞 18.32 😞 -2.28 👍
Method Length 115.03 🙂 113.80 🙂 -1.23 👍
Working memory 11.95 😞 11.84 😞 -0.11 👍
Quality 47.25% 😞 48.44% 😞 1.19% 👍
Other metrics Before After Change
Lines 12608 12369 -239
Changed files Quality Before Quality After Quality Change
assistant/init.py 94.63% ⭐ 95.23% ⭐ 0.60% 👍
assistant/api_setter.py 72.76% 🙂 73.71% 🙂 0.95% 👍
assistant/callbackstuffs.py 68.40% 🙂 69.92% 🙂 1.52% 👍
assistant/start.py 57.95% 🙂 61.58% 🙂 3.63% 👍
assistant/pmbot/banuser.py 80.64% ⭐ 81.78% ⭐ 1.14% 👍
plugins/_ChatActions.py 11.61% ⛔ 10.95% ⛔ -0.66% 👎
plugins/_help.py 36.99% 😞 33.90% 😞 -3.09% 👎
plugins/_inline.py 68.12% 🙂 68.84% 🙂 0.72% 👍
plugins/_wspr.py 38.41% 😞 38.42% 😞 0.01% 👍
plugins/admintools.py 57.17% 🙂 57.62% 🙂 0.45% 👍
plugins/afk.py 35.24% 😞 37.08% 😞 1.84% 👍
plugins/asst_cmd.py 60.55% 🙂 61.60% 🙂 1.05% 👍
plugins/autopic.py 55.43% 🙂 56.76% 🙂 1.33% 👍
plugins/bot.py 71.54% 🙂 72.38% 🙂 0.84% 👍
plugins/broadcast.py 45.24% 😞 46.86% 😞 1.62% 👍
plugins/carbon.py 61.76% 🙂 62.13% 🙂 0.37% 👍
plugins/channelhacks.py 66.19% 🙂 66.20% 🙂 0.01% 👍
plugins/chats.py 61.72% 🙂 65.19% 🙂 3.47% 👍
plugins/compressor.py 5.12% ⛔ 8.86% ⛔ 3.74% 👍
plugins/converter.py 62.72% 🙂 66.08% 🙂 3.36% 👍
plugins/core.py 70.19% 🙂 70.90% 🙂 0.71% 👍
plugins/deezer.py 42.98% 😞 43.23% 😞 0.25% 👍
plugins/devtools.py 44.42% 😞 45.45% 😞 1.03% 👍
plugins/dm.py 67.28% 🙂 69.23% 🙂 1.95% 👍
plugins/download_upload.py 14.50% ⛔ 15.32% ⛔ 0.82% 👍
plugins/evaljs.py 66.56% 🙂 67.67% 🙂 1.11% 👍
plugins/extra.py 75.54% ⭐ 75.65% ⭐ 0.11% 👍
plugins/fedutils.py 11.64% ⛔ 11.76% ⛔ 0.12% 👍
plugins/filter.py 56.97% 🙂 57.87% 🙂 0.90% 👍
plugins/forcesubscribe.py 75.43% ⭐ 75.46% ⭐ 0.03% 👍
plugins/gdrive.py 55.52% 🙂 56.88% 🙂 1.36% 👍
plugins/get_addons.py 61.60% 🙂 62.89% 🙂 1.29% 👍
plugins/giftools.py 63.32% 🙂 64.96% 🙂 1.64% 👍
plugins/globaltools.py 34.92% 😞 40.09% 😞 5.17% 👍
plugins/google.py 57.56% 🙂 58.16% 🙂 0.60% 👍
plugins/greetings.py 55.17% 🙂 56.34% 🙂 1.17% 👍
plugins/groups.py 18.70% ⛔ 19.37% ⛔ 0.67% 👍
plugins/imagetools.py 54.99% 🙂 54.99% 🙂 0.00%
plugins/logo.py 19.63% ⛔ 19.64% ⛔ 0.01% 👍
plugins/megadl.py 46.63% 😞 48.03% 😞 1.40% 👍
plugins/mute.py 47.37% 😞 48.99% 😞 1.62% 👍
plugins/nightmode.py 79.16% ⭐ 79.29% ⭐ 0.13% 👍
plugins/notes.py 58.45% 🙂 59.35% 🙂 0.90% 👍
plugins/nsfw_filter.py 27.56% 😞 26.70% 😞 -0.86% 👎
plugins/pdftools.py 41.27% 😞 41.22% 😞 -0.05% 👎
plugins/pmpermit.py 47.99% 😞 48.01% 😞 0.02% 👍
plugins/polls.py 35.95% 😞 38.76% 😞 2.81% 👍
plugins/profile.py 71.67% 🙂 73.50% 🙂 1.83% 👍
plugins/resize.py 64.27% 🙂 64.34% 🙂 0.07% 👍
plugins/saavn.py 48.57% 😞 48.71% 😞 0.14% 👍
plugins/snips.py 57.24% 🙂 58.17% 🙂 0.93% 👍
plugins/stickertools.py 25.78% 😞 25.87% 😞 0.09% 👍
plugins/sudo.py 48.78% 😞 48.91% 😞 0.13% 👍
plugins/tag.py 14.57% ⛔ 22.41% ⛔ 7.84% 👍
plugins/tools.py 35.44% 😞 35.42% 😞 -0.02% 👎
plugins/updater.py 77.19% ⭐ 75.14% ⭐ -2.05% 👎
plugins/usage.py 61.15% 🙂 59.73% 🙂 -1.42% 👎
plugins/utilities.py 44.98% 😞 47.58% 😞 2.60% 👍
plugins/variables.py 22.62% ⛔ 26.53% 😞 3.91% 👍
plugins/vctools.py 68.89% 🙂 69.03% 🙂 0.14% 👍
plugins/warn.py 37.29% 😞 38.84% 😞 1.55% 👍
plugins/webupload.py 51.31% 🙂 54.97% 🙂 3.66% 👍
plugins/words.py 64.93% 🙂 65.08% 🙂 0.15% 👍
plugins/ziptools.py 58.50% 🙂 60.11% 🙂 1.61% 👍
resources/startup/locals.py 69.92% 🙂 71.13% 🙂 1.21% 👍
vcbot/init.py 77.74% ⭐ 77.67% ⭐ -0.07% 👎
vcbot/play.py 30.81% 😞 31.27% 😞 0.46% 👍
vcbot/playfrom.py 26.73% 😞 28.34% 😞 1.61% 👍
vcbot/radio.py 44.40% 😞 44.46% 😞 0.06% 👍
vcbot/volume.py 56.04% 🙂 56.21% 🙂 0.17% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
plugins/download_upload.py download 96 ⛔ 752 ⛔ 22 ⛔ 3.29% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
plugins/pmpermit.py permitpm 76 ⛔ 679 ⛔ 23 ⛔ 3.38% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
plugins/fedutils.py _ 87 ⛔ 640 ⛔ 22 ⛔ 3.52% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
plugins/groups.py _ 86 ⛔ 586 ⛔ 22 ⛔ 3.63% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
plugins/fedutils.py _ 85 ⛔ 584 ⛔ 21 ⛔ 4.16% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Aug 11, 2021

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 1.19%.

Quality metrics Before After Change
Complexity 20.60 😞 18.32 😞 -2.28 👍
Method Length 115.03 🙂 113.80 🙂 -1.23 👍
Working memory 11.95 😞 11.84 😞 -0.11 👍
Quality 47.25% 😞 48.44% 😞 1.19% 👍
Other metrics Before After Change
Lines 12608 12366 -242
Changed files Quality Before Quality After Quality Change
assistant/init.py 94.63% ⭐ 95.23% ⭐ 0.60% 👍
assistant/api_setter.py 72.76% 🙂 73.71% 🙂 0.95% 👍
assistant/callbackstuffs.py 68.40% 🙂 69.92% 🙂 1.52% 👍
assistant/start.py 57.95% 🙂 61.58% 🙂 3.63% 👍
assistant/pmbot/banuser.py 80.64% ⭐ 81.78% ⭐ 1.14% 👍
plugins/_ChatActions.py 11.61% ⛔ 10.95% ⛔ -0.66% 👎
plugins/_help.py 36.99% 😞 33.90% 😞 -3.09% 👎
plugins/_inline.py 68.12% 🙂 68.84% 🙂 0.72% 👍
plugins/_wspr.py 38.41% 😞 38.42% 😞 0.01% 👍
plugins/admintools.py 57.17% 🙂 57.62% 🙂 0.45% 👍
plugins/afk.py 35.24% 😞 37.08% 😞 1.84% 👍
plugins/asst_cmd.py 60.55% 🙂 61.60% 🙂 1.05% 👍
plugins/autopic.py 55.43% 🙂 56.76% 🙂 1.33% 👍
plugins/bot.py 71.54% 🙂 72.38% 🙂 0.84% 👍
plugins/broadcast.py 45.24% 😞 46.86% 😞 1.62% 👍
plugins/carbon.py 61.76% 🙂 62.13% 🙂 0.37% 👍
plugins/channelhacks.py 66.19% 🙂 66.20% 🙂 0.01% 👍
plugins/chats.py 61.72% 🙂 65.19% 🙂 3.47% 👍
plugins/compressor.py 5.12% ⛔ 8.86% ⛔ 3.74% 👍
plugins/converter.py 62.72% 🙂 66.08% 🙂 3.36% 👍
plugins/core.py 70.19% 🙂 70.90% 🙂 0.71% 👍
plugins/deezer.py 42.98% 😞 43.23% 😞 0.25% 👍
plugins/devtools.py 44.42% 😞 45.45% 😞 1.03% 👍
plugins/dm.py 67.28% 🙂 69.23% 🙂 1.95% 👍
plugins/download_upload.py 14.50% ⛔ 15.32% ⛔ 0.82% 👍
plugins/evaljs.py 66.56% 🙂 67.67% 🙂 1.11% 👍
plugins/extra.py 75.54% ⭐ 75.65% ⭐ 0.11% 👍
plugins/fedutils.py 11.64% ⛔ 11.76% ⛔ 0.12% 👍
plugins/filter.py 56.97% 🙂 57.87% 🙂 0.90% 👍
plugins/forcesubscribe.py 75.43% ⭐ 75.46% ⭐ 0.03% 👍
plugins/gdrive.py 55.52% 🙂 56.88% 🙂 1.36% 👍
plugins/get_addons.py 61.60% 🙂 62.89% 🙂 1.29% 👍
plugins/giftools.py 63.32% 🙂 64.96% 🙂 1.64% 👍
plugins/globaltools.py 34.92% 😞 40.09% 😞 5.17% 👍
plugins/google.py 57.56% 🙂 58.16% 🙂 0.60% 👍
plugins/greetings.py 55.17% 🙂 56.34% 🙂 1.17% 👍
plugins/groups.py 18.70% ⛔ 19.37% ⛔ 0.67% 👍
plugins/imagetools.py 54.99% 🙂 54.99% 🙂 0.00%
plugins/logo.py 19.63% ⛔ 19.64% ⛔ 0.01% 👍
plugins/megadl.py 46.63% 😞 48.03% 😞 1.40% 👍
plugins/mute.py 47.37% 😞 48.99% 😞 1.62% 👍
plugins/nightmode.py 79.16% ⭐ 79.29% ⭐ 0.13% 👍
plugins/notes.py 58.45% 🙂 59.35% 🙂 0.90% 👍
plugins/nsfw_filter.py 27.56% 😞 26.70% 😞 -0.86% 👎
plugins/pdftools.py 41.27% 😞 41.22% 😞 -0.05% 👎
plugins/pmpermit.py 47.99% 😞 48.01% 😞 0.02% 👍
plugins/polls.py 35.95% 😞 38.76% 😞 2.81% 👍
plugins/profile.py 71.67% 🙂 73.50% 🙂 1.83% 👍
plugins/resize.py 64.27% 🙂 64.34% 🙂 0.07% 👍
plugins/saavn.py 48.57% 😞 48.71% 😞 0.14% 👍
plugins/snips.py 57.24% 🙂 58.17% 🙂 0.93% 👍
plugins/stickertools.py 25.78% 😞 25.87% 😞 0.09% 👍
plugins/sudo.py 48.78% 😞 48.91% 😞 0.13% 👍
plugins/tag.py 14.57% ⛔ 22.41% ⛔ 7.84% 👍
plugins/tools.py 35.44% 😞 35.42% 😞 -0.02% 👎
plugins/updater.py 77.19% ⭐ 75.14% ⭐ -2.05% 👎
plugins/usage.py 61.15% 🙂 59.73% 🙂 -1.42% 👎
plugins/utilities.py 44.98% 😞 47.58% 😞 2.60% 👍
plugins/variables.py 22.62% ⛔ 26.53% 😞 3.91% 👍
plugins/vctools.py 68.89% 🙂 69.03% 🙂 0.14% 👍
plugins/warn.py 37.29% 😞 38.84% 😞 1.55% 👍
plugins/webupload.py 51.31% 🙂 54.97% 🙂 3.66% 👍
plugins/words.py 64.93% 🙂 65.08% 🙂 0.15% 👍
plugins/ziptools.py 58.50% 🙂 60.11% 🙂 1.61% 👍
resources/startup/locals.py 69.92% 🙂 71.13% 🙂 1.21% 👍
vcbot/init.py 77.74% ⭐ 77.67% ⭐ -0.07% 👎
vcbot/play.py 30.81% 😞 31.27% 😞 0.46% 👍
vcbot/playfrom.py 26.73% 😞 28.34% 😞 1.61% 👍
vcbot/radio.py 44.40% 😞 44.46% 😞 0.06% 👍
vcbot/volume.py 56.04% 🙂 56.21% 🙂 0.17% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
plugins/download_upload.py download 96 ⛔ 752 ⛔ 22 ⛔ 3.29% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
plugins/pmpermit.py permitpm 76 ⛔ 679 ⛔ 23 ⛔ 3.38% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
plugins/fedutils.py _ 87 ⛔ 640 ⛔ 22 ⛔ 3.52% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
plugins/groups.py _ 86 ⛔ 586 ⛔ 22 ⛔ 3.63% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
plugins/fedutils.py _ 85 ⛔ 584 ⛔ 21 ⛔ 4.16% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@New-dev0 New-dev0 merged commit 3ee94cc into dev Aug 11, 2021
@buddhhu
Copy link
Member

buddhhu commented Aug 12, 2021

@sourcery-ai[bot] Rip @sppidy's update codes

@xditya
Copy link
Member

xditya commented Aug 12, 2021

@buddhhu Please stop usig that

@New-dev0 New-dev0 deleted the sourcery/dev branch August 17, 2021 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants