fix status command
This commit is contained in:
parent
8ea2231379
commit
e08a3e55b0
2 changed files with 12 additions and 3 deletions
7
app.py
7
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
|
||||
|
||||
|
||||
|
|
8
lib.py
8
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])
|
||||
|
|
Loading…
Reference in a new issue