A lightweight program for tracking the number of players and notifying you when there are 0.
This commit is contained in:
21
main.py
Normal file
21
main.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import os
|
||||||
|
import time
|
||||||
|
import subprocess
|
||||||
|
from mcstatus import JavaServer
|
||||||
|
|
||||||
|
server = JavaServer.lookup(os.getenv("SERVER"))
|
||||||
|
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
status = server.status()
|
||||||
|
players = status.players.online
|
||||||
|
|
||||||
|
print(f"Игроков: {players}")
|
||||||
|
if players == 0:
|
||||||
|
subprocess.run(["notify-send", "MC_Status", "Сервер пуст!"])
|
||||||
|
subprocess.Popen(["mpg123", "sound.mp3"])
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Ошибка подключения: {e}")
|
||||||
|
|
||||||
|
time.sleep(30)
|
||||||
Reference in New Issue
Block a user