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")
|
await message.channel.send(f"Sorry {message.author.mention}, that didn't work. Ping @lauralani")
|
||||||
|
|
||||||
if messagearray[0] == "status":
|
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
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
8
lib.py
8
lib.py
|
@ -11,8 +11,12 @@ def BuildGameList():
|
||||||
|
|
||||||
return retlist
|
return retlist
|
||||||
|
|
||||||
def BuildSingleGameStatus(game):
|
def BuildSingleGameStatus(slug: str):
|
||||||
return f"**{game['displayname']}**\n- Status: **{CheckSystemdService(game['systemd'])}**\n- Slug: `{game['slug']}`"
|
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):
|
def CheckSystemdService(service : str):
|
||||||
stat = subprocess.call(["systemctl", "is-active", "--quiet", service])
|
stat = subprocess.call(["systemctl", "is-active", "--quiet", service])
|
||||||
|
|
Loading…
Reference in a new issue