commit 835d73474bd943e99880a108ba1e5a54472c8a3d Author: Ozi-s Date: Tue Aug 11 21:23:23 2026 +0300 A lightweight program for tracking the number of players and notifying you when there are 0. diff --git a/main.py b/main.py new file mode 100644 index 0000000..49d8f00 --- /dev/null +++ b/main.py @@ -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) diff --git a/sound.mp3 b/sound.mp3 new file mode 100644 index 0000000..597ca49 Binary files /dev/null and b/sound.mp3 differ