Files
Blitz-Proxy/core/scripts/telegrambot/utils/command.py
Whispering Wind 38452a0959 Create command
2024-12-15 00:32:13 +03:30

26 lines
720 B
Python

import telebot
import subprocess
import json
import os
import shlex
from dotenv import load_dotenv
from telebot import types
load_dotenv()
API_TOKEN = os.getenv('API_TOKEN')
ADMIN_USER_IDS = json.loads(os.getenv('ADMIN_USER_IDS'))
CLI_PATH = '/etc/hysteria/core/cli.py'
BACKUP_DIRECTORY = '/opt/hysbackup'
bot = telebot.TeleBot(API_TOKEN)
def run_cli_command(command):
try:
args = shlex.split(command)
result = subprocess.check_output(args, stderr=subprocess.STDOUT)
return result.decode('utf-8').strip()
except subprocess.CalledProcessError as e:
return f'Error: {e.output.decode("utf-8")}'
def is_admin(user_id):
return user_id in ADMIN_USER_IDS