fix status command

This commit is contained in:
Adora Laura Kalb 2024-01-01 15:12:32 +01:00
parent 8ea2231379
commit e08a3e55b0
Signed by: adoralaura
GPG key ID: 7A4552166FC8C056
2 changed files with 12 additions and 3 deletions

7
app.py
View file

@ -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

6
lib.py
View file

@ -11,8 +11,12 @@ def BuildGameList():
return retlist
def BuildSingleGameStatus(game):
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])