feat(api): add endpoint to get telegram backup interval
This commit is contained in:
@ -14,6 +14,7 @@ CONFIG_FILE = '/etc/hysteria/config.json'
|
||||
CONFIG_ENV_FILE = '/etc/hysteria/.configs.env'
|
||||
WEBPANEL_ENV_FILE = '/etc/hysteria/core/scripts/webpanel/.env'
|
||||
NORMALSUB_ENV_FILE = '/etc/hysteria/core/scripts/normalsub/.env'
|
||||
TELEGRAM_ENV_FILE = '/etc/hysteria/core/scripts/telegrambot/.env'
|
||||
NODES_JSON_PATH = "/etc/hysteria/nodes.json"
|
||||
|
||||
|
||||
@ -581,6 +582,26 @@ def stop_telegram_bot():
|
||||
'''Stops the Telegram bot.'''
|
||||
run_cmd(['python3', Command.INSTALL_TELEGRAMBOT.value, 'stop'])
|
||||
|
||||
def get_telegram_bot_backup_interval() -> int | None:
|
||||
'''Retrievels the current BACKUP_INTERVAL_HOUR for the Telegram Bot service from its .env file.'''
|
||||
try:
|
||||
if not os.path.exists(TELEGRAM_ENV_FILE):
|
||||
return None
|
||||
|
||||
env_vars = dotenv_values(TELEGRAM_ENV_FILE)
|
||||
interval_str = env_vars.get('BACKUP_INTERVAL_HOUR')
|
||||
|
||||
if interval_str:
|
||||
try:
|
||||
return int(float(interval_str))
|
||||
except (ValueError, TypeError):
|
||||
return None
|
||||
|
||||
return None
|
||||
except Exception as e:
|
||||
print(f"Error reading Telegram Bot .env file: {e}")
|
||||
return None
|
||||
|
||||
def set_telegram_bot_backup_interval(backup_interval: int):
|
||||
'''Sets the backup interval for the Telegram bot.'''
|
||||
if backup_interval is None:
|
||||
|
||||
Reference in New Issue
Block a user