From 93037d280f28935ebdc09c445782c07ce760ba49 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Wed, 12 Mar 2025 11:11:54 +0330 Subject: [PATCH] feat: Add version check and notification new releases --- core/scripts/telegrambot/tbot.py | 3 +++ .../telegrambot/utils/check_version.py | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 core/scripts/telegrambot/utils/check_version.py diff --git a/core/scripts/telegrambot/tbot.py b/core/scripts/telegrambot/tbot.py index 6c06904..eb44865 100644 --- a/core/scripts/telegrambot/tbot.py +++ b/core/scripts/telegrambot/tbot.py @@ -8,6 +8,7 @@ from utils.edituser import * from utils.search import * from utils.serverinfo import * from utils.cpu import * +from utils.check_version import * import threading import time @@ -27,4 +28,6 @@ def monitoring_thread(): if __name__ == '__main__': monitor_thread = threading.Thread(target=monitoring_thread, daemon=True) monitor_thread.start() + version_thread = threading.Thread(target=version_monitoring, daemon=True) + version_thread.start() bot.polling(none_stop=True) diff --git a/core/scripts/telegrambot/utils/check_version.py b/core/scripts/telegrambot/utils/check_version.py new file mode 100644 index 0000000..c47a754 --- /dev/null +++ b/core/scripts/telegrambot/utils/check_version.py @@ -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)