Skip to content

Commit

Permalink
modules: post: Fetch changelog url from maintainers.json
Browse files Browse the repository at this point in the history
  • Loading branch information
pranayadmn committed Jul 31, 2024
1 parent d7513d9 commit 742529b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions statixbot/modules/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,14 @@ async def register(self, app: Client) -> None:
async def post_message(client: Client, message: Message) -> None:
try:
args: str = message.text.split(maxsplit=2)
if len(args) < 2:
if len(args) != 2:
await message.reply_text(
"Usage: /post <code>&lt;codename&gt;</code> <code>[changelog]</code>",
"Usage: /post <code>&lt;codename&gt;</code>",
parse_mode=ParseMode.HTML,
)
return

codename: str = args[1]
changelog: str = args[2] if len(args) == 3 else ""

if codename not in JSON_DATA:
await message.reply_text(f"Codename `{codename}` not found in database.")
Expand All @@ -68,6 +67,7 @@ async def post_message(client: Client, message: Message) -> None:
data: Dict = JSON_DATA
release: Dict = data.get("release", {})
device: Dict = data.get(codename, {})
changelog: str = device.get("changelog", "")

message_text: str = (
f"#{codename} #{release.get('branch', 'unknown')}\n"
Expand All @@ -77,7 +77,9 @@ async def post_message(client: Client, message: Message) -> None:
)

if changelog:
message_text += f" | [Changelog]({changelog})"
message_text += f" | [Changelog](https://xdaforums.com/t/{changelog})"
else:
message_text += f" | [Changelog](https://downloads.statixos.com/{release.get('version', 'Unknown')}-{release.get('codename', 'Unknown')}/{codename}/changelog.txt)"

await client.send_message(
chat_id="-1001238532711",
Expand All @@ -92,6 +94,6 @@ async def post_message(client: Client, message: Message) -> None:
await message.reply_text("An error occurred while posting the message.")

add_cmd(
"post <code>&lt;codename&gt;</code> <code>[changelog]</code>",
"post <code>&lt;codename&gt;</code>",
"Post a new build to @StatiXOSReleases.",
)

0 comments on commit 742529b

Please sign in to comment.