From e08a3e55b00338faae978e221057a0f0529b86e9 Mon Sep 17 00:00:00 2001 From: lauralani Date: Mon, 1 Jan 2024 15:12:32 +0100 Subject: [PATCH] fix status command --- app.py | 7 ++++++- lib.py | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index ffb6f34..db2e83f 100644 --- a/app.py +++ b/app.py @@ -67,7 +67,12 @@ async def on_message(message): await message.channel.send(f"Sorry {message.author.mention}, that didn't work. Ping @lauralani") if messagearray[0] == "status": - await message.channel.send(BuildSingleGameStatus(messagearray[1])) + status = BuildSingleGameStatus(messagearray[1]) + if not status: + await message.add_reaction("❌") + await message.channel.send(f"Invalid game: {messagearray[1]}") + return + await message.channel.send(status) return diff --git a/lib.py b/lib.py index 7c1fbfa..784558d 100644 --- a/lib.py +++ b/lib.py @@ -11,8 +11,12 @@ def BuildGameList(): return retlist -def BuildSingleGameStatus(game): - return f"**{game['displayname']}**\n- Status: **{CheckSystemdService(game['systemd'])}**\n- Slug: `{game['slug']}`" +def BuildSingleGameStatus(slug: str): + game = GetGameByGameSlug(slug) + if game: + return f"**{game['displayname']}**\n- Status: **{CheckSystemdService(game['systemd'])}**\n- Slug: `{game['slug']}`" + else: + return False def CheckSystemdService(service : str): stat = subprocess.call(["systemctl", "is-active", "--quiet", service])