diff --git a/core/scripts/hysteria2/add_user.sh b/core/scripts/hysteria2/add_user.sh index 45faffa..267c265 100644 --- a/core/scripts/hysteria2/add_user.sh +++ b/core/scripts/hysteria2/add_user.sh @@ -53,7 +53,7 @@ add_user() { '.[$username] = {password: $password, max_download_bytes: $traffic, expiration_days: $expiration_days, account_creation_date: $creation_date, blocked: false}' \ "$USERS_FILE" > "${USERS_FILE}.temp" && mv "${USERS_FILE}.temp" "$USERS_FILE" - python3 "$CLI_PATH" restart-hysteria2 > /dev/null 2>&1 + # python3 "$CLI_PATH" restart-hysteria2 > /dev/null 2>&1 echo -e "User $username added successfully." } diff --git a/core/scripts/hysteria2/install.sh b/core/scripts/hysteria2/install.sh index ced4082..cd78bcc 100644 --- a/core/scripts/hysteria2/install.sh +++ b/core/scripts/hysteria2/install.sh @@ -119,8 +119,8 @@ EOF chmod +x /etc/hysteria/core/scripts/hysteria2/kick.sh # Add the scripts to the crontab - (crontab -l ; echo "*/1 * * * * python3 /etc/hysteria/core/cli.py traffic-status >/dev/null 2>&1") | crontab - - (crontab -l ; echo "*/1 * * * * /etc/hysteria/core/scripts/hysteria2/kick.sh >/dev/null 2>&1") | crontab - + (crontab -l ; echo "*/1 * * * * /bin/bash -c 'source /etc/hysteria/hysteria2_venv/bin/activate && python3 /etc/hysteria/core/cli.py traffic-status' >/dev/null 2>&1") | crontab - + (crontab -l ; echo "*/1 * * * * /bin/bash -c 'source /etc/hysteria/hysteria2_venv/bin/activate && /etc/hysteria/core/scripts/hysteria2/kick.sh' >/dev/null 2>&1") | crontab - } if systemctl is-active --quiet hysteria-server.service; then diff --git a/core/scripts/telegrambot/tbot.py b/core/scripts/telegrambot/tbot.py index 2c06ebb..28163b4 100644 --- a/core/scripts/telegrambot/tbot.py +++ b/core/scripts/telegrambot/tbot.py @@ -82,7 +82,20 @@ def process_add_user_step3(message, username, traffic_limit): expiration_days = int(message.text.strip()) command = f"python3 {CLI_PATH} add-user -u {username} -t {traffic_limit} -e {expiration_days}" result = run_cli_command(command) - bot.reply_to(message, result) + qr_command = f"python3 {CLI_PATH} show-user-uri -u {username} -ip 4" + qr_result = run_cli_command(qr_command) + + if qr_result.strip() == "": + bot.reply_to(message, "Failed to generate QR code.") + return + + qr_v4 = qrcode.make(qr_result) + bio_v4 = io.BytesIO() + qr_v4.save(bio_v4, 'PNG') + bio_v4.seek(0) + caption = f"{result}" + bot.send_photo(message.chat.id, photo=bio_v4, caption=caption) + except ValueError: bot.reply_to(message, "Invalid expiration days. Please enter a number.") diff --git a/menu.sh b/menu.sh index 2c7745a..b7d092f 100644 --- a/menu.sh +++ b/menu.sh @@ -267,7 +267,7 @@ telegram_bot_handler() { echo "The hysteria-bot.service is already active." else while true; do - read -p "Enter the Telegram bot token: " token + read -e -p "Enter the Telegram bot token: " token if [ -z "$token" ]; then echo "Token cannot be empty. Please try again." else @@ -276,7 +276,7 @@ telegram_bot_handler() { done while true; do - read -p "Enter the admin IDs (comma-separated): " admin_ids + read -e -p "Enter the admin IDs (comma-separated): " admin_ids if [ -z "$admin_ids" ]; then echo "Admin IDs cannot be empty. Please try again." else @@ -317,7 +317,7 @@ singbox_handler() { echo "The singbox.service is already active." else while true; do - read -p "Enter the domain name for the SSL certificate: " domain + read -e -p "Enter the domain name for the SSL certificate: " domain if [ -z "$domain" ]; then echo "Domain name cannot be empty. Please try again." else @@ -326,7 +326,7 @@ singbox_handler() { done while true; do - read -p "Enter the port number for the service: " port + read -e -p "Enter the port number for the service: " port if [ -z "$port" ]; then echo "Port number cannot be empty. Please try again." elif ! [[ "$port" =~ ^[0-9]+$ ]]; then