feat: Add version check and notification new releases

This commit is contained in:
Whispering Wind
2025-03-12 11:11:54 +03:30
committed by GitHub
parent 82c736b261
commit 93037d280f
2 changed files with 26 additions and 0 deletions

View File

@ -8,6 +8,7 @@ from utils.edituser import *
from utils.search import * from utils.search import *
from utils.serverinfo import * from utils.serverinfo import *
from utils.cpu import * from utils.cpu import *
from utils.check_version import *
import threading import threading
import time import time
@ -27,4 +28,6 @@ def monitoring_thread():
if __name__ == '__main__': if __name__ == '__main__':
monitor_thread = threading.Thread(target=monitoring_thread, daemon=True) monitor_thread = threading.Thread(target=monitoring_thread, daemon=True)
monitor_thread.start() monitor_thread.start()
version_thread = threading.Thread(target=version_monitoring, daemon=True)
version_thread.start()
bot.polling(none_stop=True) bot.polling(none_stop=True)

View File

@ -0,0 +1,23 @@
import telebot
import subprocess
import shlex
import time
from utils.command import *
def check_version():
command = f"python3 {CLI_PATH} check-version"
try:
args = shlex.split(command)
result = subprocess.check_output(args, stderr=subprocess.STDOUT).decode("utf-8").strip()
notify_admins(result)
except subprocess.CalledProcessError as e:
print(f"Error checking version: {e.output.decode('utf-8')}")
def notify_admins(message):
for admin_id in ADMIN_USER_IDS:
bot.send_message(admin_id, message)
def version_monitoring():
while True:
check_version()
time.sleep(86400)