A lightweight program for tracking the number of players and notifying you when there are 0.

This commit is contained in:
2026-08-11 21:23:23 +03:00
commit 835d73474b
2 changed files with 21 additions and 0 deletions

21
main.py Normal file
View 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)