feat: Add version check and notification new releases
This commit is contained in:
@ -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)
|
||||
|
||||
23
core/scripts/telegrambot/utils/check_version.py
Normal file
23
core/scripts/telegrambot/utils/check_version.py
Normal 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)
|
||||
Reference in New Issue
Block a user