From 742529bd52db9a627f58362acdb070bda1f4023b Mon Sep 17 00:00:00 2001 From: Pranaya Deomani Date: Wed, 31 Jul 2024 16:13:25 +0530 Subject: [PATCH] modules: post: Fetch changelog url from maintainers.json --- statixbot/modules/post.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/statixbot/modules/post.py b/statixbot/modules/post.py index 244d33a..b31efe8 100644 --- a/statixbot/modules/post.py +++ b/statixbot/modules/post.py @@ -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 <codename> [changelog]", + "Usage: /post <codename>", 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.") @@ -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" @@ -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", @@ -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 <codename> [changelog]", + "post <codename>", "Post a new build to @StatiXOSReleases.", )