diff --git a/ProjectMan/modules/help.py b/ProjectMan/modules/help.py
index 01cb7ae..40d1895 100644
--- a/ProjectMan/modules/help.py
+++ b/ProjectMan/modules/help.py
@@ -57,11 +57,7 @@ async def module_help(client: Client, message: Message):
def add_command_help(module_name, commands):
- if module_name in CMD_HELP.keys():
- command_dict = CMD_HELP[module_name]
- else:
- command_dict = {}
-
+ command_dict = CMD_HELP[module_name] if module_name in CMD_HELP.keys() else {}
for x in commands:
for y in x:
if y is not x:
diff --git a/ProjectMan/modules/updater.py b/ProjectMan/modules/updater.py
index 92cdd12..1aa04a4 100644
--- a/ProjectMan/modules/updater.py
+++ b/ProjectMan/modules/updater.py
@@ -54,13 +54,11 @@ async def is_heroku():
async def gen_chlog(repo, diff):
- ch_log = ""
d_form = "%d/%m/%y"
- for c in repo.iter_commits(diff):
- ch_log += (
- f"• [{c.committed_datetime.strftime(d_form)}]: {c.summary} <{c.author}>\n"
- )
- return ch_log
+ return "".join(
+ f"• [{c.committed_datetime.strftime(d_form)}]: {c.summary} <{c.author}>\n"
+ for c in repo.iter_commits(diff)
+ )
async def updateme_requirements():
@@ -100,8 +98,6 @@ async def upstream(client: Client, message: Message):
repo.__del__()
return
except InvalidGitRepositoryError:
- if conf != "deploy":
- pass
repo = Repo.init()
origin = repo.create_remote("upstream", off_repo)
origin.fetch()
@@ -128,23 +124,21 @@ async def upstream(client: Client, message: Message):
if "deploy" not in conf:
if changelog:
changelog_str = f"**Tersedia Pembaruan Untuk Branch [{ac_br}]:\n\nCHANGELOG:**\n\n`{changelog}`"
- if len(changelog_str) > 4096:
- await status.edit("**Changelog terlalu besar, dikirim sebagai file.**")
- file = open("output.txt", "w+")
- file.write(changelog_str)
- file.close()
- await client.send_document(
- message.chat.id,
- "output.txt",
- caption=f"**Ketik** `{cmd}update deploy` **Untuk Mengupdate Userbot.**",
- reply_to_message_id=status.id,
- )
- remove("output.txt")
- else:
+ if len(changelog_str) <= 4096:
return await status.edit(
f"{changelog_str}\n**Ketik** `{cmd}update deploy` **Untuk Mengupdate Userbot.**",
disable_web_page_preview=True,
)
+ await status.edit("**Changelog terlalu besar, dikirim sebagai file.**")
+ with open("output.txt", "w+") as file:
+ file.write(changelog_str)
+ await client.send_document(
+ message.chat.id,
+ "output.txt",
+ caption=f"**Ketik** `{cmd}update deploy` **Untuk Mengupdate Userbot.**",
+ reply_to_message_id=status.id,
+ )
+ remove("output.txt")
else:
await status.edit(
f"\n`Your BOT is` **up-to-date** `with branch` **[{ac_br}]**\n",
@@ -156,7 +150,6 @@ async def upstream(client: Client, message: Message):
import heroku3
heroku = heroku3.from_key(HEROKU_API_KEY)
- heroku_app = None
heroku_applications = heroku.apps()
if not HEROKU_APP_NAME:
await status.edit(
@@ -164,10 +157,14 @@ async def upstream(client: Client, message: Message):
)
repo.__del__()
return
- for app in heroku_applications:
- if app.name == HEROKU_APP_NAME:
- heroku_app = app
- break
+ heroku_app = next(
+ (
+ app
+ for app in heroku_applications
+ if app.name == HEROKU_APP_NAME
+ ),
+ None,
+ )
if heroku_app is None:
await status.edit(
f"{txt}\n`Invalid Heroku credentials for updating userbot dyno.`"
@@ -180,7 +177,7 @@ async def upstream(client: Client, message: Message):
ups_rem.fetch(ac_br)
repo.git.reset("--hard", "FETCH_HEAD")
heroku_git_url = heroku_app.git_url.replace(
- "https://", "https://api:" + HEROKU_API_KEY + "@"
+ "https://", f"https://api:{HEROKU_API_KEY}@"
)
if "heroku" in repo.remotes:
remote = repo.remote("heroku")
@@ -233,13 +230,14 @@ async def updaterman(client: Client, message: Message):
verification = str(checks.count())
if verification == "":
return await response.edit("Bot is up-to-date!")
- updates = ""
ordinal = lambda format: "%d%s" % (
format,
"tsnrhtdd"[(format // 10 % 10 != 1) * (format % 10 < 4) * format % 10 :: 4],
)
- for info in repo.iter_commits(f"HEAD..origin/{BRANCH}"):
- updates += f"➣ #{info.count()}: [{info.summary}]({REPO_}/commit/{info}) by -> {info.author}\n\t\t\t\t➥ Commited on: {ordinal(int(datetime.fromtimestamp(info.committed_date).strftime('%d')))} {datetime.fromtimestamp(info.committed_date).strftime('%b')}, {datetime.fromtimestamp(info.committed_date).strftime('%Y')}\n\n"
+ updates = "".join(
+ f"➣ #{info.count()}: [{info.summary}]({REPO_}/commit/{info}) by -> {info.author}\n\t\t\t\t➥ Commited on: {ordinal(int(datetime.fromtimestamp(info.committed_date).strftime('%d')))} {datetime.fromtimestamp(info.committed_date).strftime('%b')}, {datetime.fromtimestamp(info.committed_date).strftime('%Y')}\n\n"
+ for info in repo.iter_commits(f"HEAD..origin/{BRANCH}")
+ )
_update_response_ = "A new update is available for the Bot!\n\n➣ Pushing Updates Now\n\n**Updates:**\n\n"
_final_updates_ = _update_response_ + updates
if len(_final_updates_) > 4096: