#!/bin/bash
biji=$(date +"%Y-%m-%d" -d "$dateFromServer")
colornow=$(cat /etc/rmbl/theme/color.conf)
NC="\e[0m"
RED="\033[0;31m"
COLOR1="$(cat /etc/rmbl/theme/$colornow | grep -w "TEXT" | cut -d: -f2 | sed 's/ //g')"
COLBG1="$(cat /etc/rmbl/theme/$colornow | grep -w "BG" | cut -d: -f2 | sed 's/ //g')"
WH='\033[1;37m'
clear
ISP=$(cat /etc/xray/isp)
CITY=$(cat /etc/xray/city)
author=$(cat /etc/profil)
TIMES="10"
CHATID=$(cat /etc/per/id)
KEY=$(cat /etc/per/token)
URL="https://api.telegram.org/bot$KEY/sendMessage"
domain=$(cat /etc/xray/domain)
CHATID2=$(cat /etc/perlogin/id)
KEY2=$(cat /etc/perlogin/token)
URL2="https://api.telegram.org/bot$KEY2/sendMessage"
cd
if [ ! -e /etc/vless/akun ]; then
    mkdir -p /etc/vless/akun
fi
function add-vless() {
    clear
    until [[ $user =~ ^[a-zA-Z0-9_.-]+$ && ${CLIENT_EXISTS} == '0' ]]; do
        echo -e "$COLOR1╭═════════════════════════════════════════════════╮${NC}"
        echo -e "$COLOR1│${NC} ${COLBG1}           ${WH}• Add Vless Account •               ${NC} $COLOR1│ $NC"
        echo -e "$COLOR1╰═════════════════════════════════════════════════╯${NC}"
        echo -e ""
        read -rp "User: " -e user
        CLIENT_EXISTS=$(grep -w $user /etc/xray/config.json | wc -l)
        if [[ ${CLIENT_EXISTS} == '1' ]]; then
            clear
            echo -e "$COLOR1╭═════════════════════════════════════════════════╮${NC}"
            echo -e "$COLOR1│${NC} ${COLBG1}           ${WH}• Add Vless Account •               ${NC} $COLOR1│ $NC"
            echo -e "$COLOR1╰═════════════════════════════════════════════════╯${NC}"
            echo -e "$COLOR1╭═════════════════════════════════════════════════╮${NC}"
            echo -e "$COLOR1│                                                 │"
            echo -e "$COLOR1│${WH} Nama Duplikat Silahkan Buat Nama Lain.          $COLOR1│"
            echo -e "$COLOR1│                                                 │"
            echo -e "$COLOR1╰═════════════════════════════════════════════════╯${NC}"
            read -n 1 -s -r -p "Press any key to back"
            add-vless
        fi
    done
    uuid=$(cat /proc/sys/kernel/random/uuid)
    until [[ $masaaktif =~ ^[0-9]+$ ]]; do
        read -p "Expired (hari): " masaaktif
    done
    until [[ $iplim =~ ^[0-9]+$ ]]; do
        read -p "Limit User (IP) or 0 Unlimited: " iplim
    done
    until [[ $Quota =~ ^[0-9]+$ ]]; do
        read -p "Limit User (GB) or 0 Unlimited: " Quota
    done
    if [ ! -e /etc/vless ]; then
        mkdir -p /etc/vless
    fi
    if [ ${iplim} = '0' ]; then
        iplim="9999"
    fi
    if [ ${Quota} = '0' ]; then
        Quota="9999"
    fi
    c=$(echo "${Quota}" | sed 's/[^0-9]*//g')
    d=$((${c} * 1024 * 1024 * 1024))
    if [[ ${c} != "0" ]]; then
        echo "${d}" >/etc/vless/${user}
    fi
    echo "${iplim}" >/etc/vless/${user}IP
    exp=$(date -d "$masaaktif days" +"%Y-%m-%d")
    sed -i '/#vless$/a\#vl '"$user $exp $uuid"'\
},{"id": "'""$uuid""'","email": "'""$user""'"' /etc/xray/config.json
    sed -i '/#vlessgrpc$/a\#vlg '"$user $exp"'\
},{"id": "'""$uuid""'","email": "'""$user""'"' /etc/xray/config.json
    vlesslink1="vless://${uuid}@${domain}:443?path=/vless&security=tls&encryption=none&host=${domain}&type=ws&sni=${domain}#${user}"
    vlesslink2="vless://${uuid}@${domain}:80?path=/vless&security=none&encryption=none&host=${domain}&type=ws#${user}"
    vlesslink3="vless://${uuid}@${domain}:443?mode=gun&security=tls&encryption=none&type=grpc&serviceName=vless-grpc&sni=${domain}#${user}"
    vless1="vless://${uuid}@${domain}:443?path=/vless%26security=tls%26encryption=none%26host=${domain}%26type=ws%26sni=${domain}#${user}"
    vless2="vless://${uuid}@${domain}:80?path=/vless%26security=none%26encryption=none%26host=${domain}%26type=ws#${user}"
    vless3="vless://${uuid}@${domain}:443?mode=gun%26security=tls%26encryption=none%26type=grpc%26serviceName=vless-grpc%26sni=${domain}#${user}"
    cat >/home/vps/public_html/vless-$user.txt <<-END
_______________________________
Format Vless WS (CDN)
_______________________________
- name: vless-$user-WS (CDN)
server: ${domain}
port: 443
type: vless
uuid: ${uuid}
cipher: auto
tls: true
skip-cert-verify: true
servername: ${domain}
network: ws
udp: true
ws-opts:
path: /vless
headers:
Host: ${domain}
_______________________________
Format Vless WS (CDN) Non TLS
_______________________________
- name: vless-$user-WS (CDN) Non TLS
server: ${domain}
port: 80
type: vless
uuid: ${uuid}
cipher: auto
tls: false
skip-cert-verify: false
servername: ${domain}
network: ws
ws-opts:
udp: true
path: /vless
headers:
Host: ${domain}
_______________________________
Format Vless gRPC (SNI)
_______________________________
- name: vless-$user-gRPC (SNI)
server: ${domain}
port: 443
type: vless
uuid: ${uuid}
cipher: auto
tls: true
skip-cert-verify: true
servername: ${domain}
network: grpc
grpc-opts:
grpc-mode: gun
grpc-service-name: vless-grpc
udp: true
_______________________________
Link Vless Account
_______________________________
Link TLS : vless://${uuid}@${domain}:443?path=/vless&security=tls&encryption=none&host=${domain}&type=ws&sni=${domain}#${user}
_______________________________
Link none TLS : vless://${uuid}@${domain}:80?path=/vless&security=none&encryption=none&host=${domain}&type=ws#${user}
_______________________________
Link GRPC : vless://${uuid}@${domain}:443?mode=gun&security=tls&encryption=none&type=grpc&serviceName=vless-grpc&sni=${domain}#${user}
_______________________________
END
    if [ ${Quota} = '9999' ]; then
        TEXT="
◇━━━━━━━━━━━━━━━━━◇
Premium Vless Account
◇━━━━━━━━━━━━━━━━━◇
User         : ${user}
Domain       : <code>${domain}</code>
Login Limit  : ${iplim} IP
ISP          : ${ISP}
CITY         : ${CITY}
Port TLS     : 443
Port NTLS    : 80, 8080
Port GRPC    : 443
UUID         : <code>${uuid}</code>
AlterId      : 0
Security     : auto
Network      : WS or gRPC
Path vless   : <code>/vless</code>
ServiceName  : <code>/vless-grpc</code>
◇━━━━━━━━━━━━━━━━━◇
Link TLS     :
<code>${vless1}</code>
◇━━━━━━━━━━━━━━━━━◇
Link NTLS    :
<code>${vless2}</code>
◇━━━━━━━━━━━━━━━━━◇
Link gRPC    :
<code>${vless3}</code>
◇━━━━━━━━━━━━━━━━━◇
Format OpenClash :
http://$domain:89/vless-$user.txt
◇━━━━━━━━━━━━━━━━━◇
Expired Until    : $exp
◇━━━━━━━━━━━━━━━━━◇
$author
◇━━━━━━━━━━━━━━━━━◇
"
    else
        TEXT="
◇━━━━━━━━━━━━━━━━━◇
Premium Vless Account
◇━━━━━━━━━━━━━━━━━◇
User         : ${user}
Domain       : <code>${domain}</code>
Login Limit  : ${iplim} IP
Quota Limit  : ${Quota} GB
ISP          : ${ISP}
CITY         : ${CITY}
Port TLS     : 443
Port NTLS    : 80, 8080
Port GRPC    : 443
UUID         : <code>${uuid}</code>
AlterId      : 0
Security     : auto
Network      : WS or gRPC
Path vless   : <code>/vless</code>
ServiceName  : <code>/vless-grpc</code>
◇━━━━━━━━━━━━━━━━━◇
Link TLS     :
<code>${vless1}</code>
◇━━━━━━━━━━━━━━━━━◇
Link NTLS    :
<code>${vless2}</code>
◇━━━━━━━━━━━━━━━━━◇
Link GRPC    :
<code>${vless3}</code>
◇━━━━━━━━━━━━━━━━━◇
Format OpenClash :
http://$domain:89/vless-$user.txt
◇━━━━━━━━━━━━━━━━━◇
Expired Until    : $exp
◇━━━━━━━━━━━━━━━━━◇
$author
◇━━━━━━━━━━━━━━━━━◇
"
    fi
    curl -s --max-time $TIMES -d "chat_id=$CHATID&disable_web_page_preview=1&text=$TEXT&parse_mode=html" $URL >/dev/null
    cd
    if [ ! -e /etc/tele ]; then
        echo -ne
    else
        echo "$TEXT" >/etc/notiftele
        bash /etc/tele
    fi
    user2=$(echo "$user" | cut -c 1-3)
    TIME2=$(date +'%Y-%m-%d %H:%M:%S')
    TEXT2="
<code>◇━━━━━━━━━━━━━━━━━━━◇</code>
<b>   PEMBELIAN VLESS SUCCES </b>
<code>◇━━━━━━━━━━━━━━━━━━━◇</code>
<b>DOMAIN  :</b> <code>${domain} </code>
<b>CITY    :</b> <code>$CITY </code>
<b>DATE    :</b> <code>${TIME2} WIB </code>
<b>DETAIL  :</b> <code>Trx VLESS </code>
<b>USER    :</b> <code>${user2}xxx </code>
<b>IP      :</b> <code>${iplim} IP </code>
<b>DURASI  :</b> <code>$masaaktif Hari </code>
<code>◇━━━━━━━━━━━━━━━━━━━◇</code>
<i>Notif Pembelian Akun Vless..</i>"
    curl -s --max-time $TIMES -d "chat_id=$CHATID2&disable_web_page_preview=1&text=$TEXT2&parse_mode=html" $URL2 >/dev/null
    clear
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}• Premium Vless Account •${NC} $COLOR1 $NC" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}User         ${COLOR1}: ${WH}${user}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}ISP          ${COLOR1}: ${WH}$ISP" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}City         ${COLOR1}: ${WH}$CITY" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Domain       ${COLOR1}: ${WH}${domain}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Login Limit  ${COLOR1}: ${WH}${iplim} IP" | tee -a /etc/vless/akun/log-create-${user}.log
    if [ ${Quota} = '9999' ]; then
        echo -ne
    else
        echo -e "$COLOR1 ${NC} ${WH}Quota Limit  ${COLOR1}: ${WH}${Quota} GB" | tee -a /etc/vless/akun/log-create-${user}.log
    fi
    echo -e "$COLOR1 ${NC} ${WH}Port TLS     ${COLOR1}: ${WH}443" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Port NTLS    ${COLOR1}: ${WH}80,8080" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Port gRPC    ${COLOR1}: ${WH}443" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}UUID         ${COLOR1}: ${WH}${uuid}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Encryption   ${COLOR1}: ${WH}none" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Network      ${COLOR1}: ${WH}ws" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Path         ${COLOR1}: ${WH}/vless" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Path grpc    ${COLOR1}: ${WH}/vless-grpc" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${COLOR1}Link Websocket TLS      ${WH}:${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}${vlesslink1}${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${COLOR1}Link Websocket NTLS  ${WH}:${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}${vlesslink2}${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${COLOR1}Link gRPC               ${WH}:${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}${vlesslink3}${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Format Openclash ${COLOR1}: " | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}http://$domain:89/vless-$user.txt${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Expired Until   ${COLOR1}: ${WH}$exp" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}    $author    " | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo "" | tee -a /etc/vless/akun/log-create-${user}.log
    systemctl restart xray >/dev/null 2>&1
    read -n 1 -s -r -p "Press any key to back on menu"
    menu
}
function trial-vless() {
    clear
    cd
    echo -e "$COLOR1╭═════════════════════════════════════════════════╮${NC}"
    echo -e "$COLOR1 ${NC}${COLBG1}            ${WH}• Trial Vless Account •             ${NC} $COLOR1 $NC"
    echo -e "$COLOR1╰═════════════════════════════════════════════════╯${NC}"
    until [[ $timer =~ ^[0-9]+$ ]]; do
        read -p "Expired (Minutes): " timer
    done
    user=Trial-$(tr </dev/urandom -dc X-Z0-9 | head -c4)
    uuid=$(cat /proc/sys/kernel/random/uuid)
    masaaktif=0
    iplim=1
    Quota=10
    if [ ! -e /etc/vless ]; then
        mkdir -p /etc/vless
    fi
    c=$(echo "${Quota}" | sed 's/[^0-9]*//g')
    d=$((${c} * 1024 * 1024 * 1024))
    if [[ ${c} != "0" ]]; then
        echo "${d}" >/etc/vless/${user}
    fi
    echo "${iplim}" >/etc/vless/${user}IP
    exp=$(date -d "$masaaktif days" +"%Y-%m-%d")
    sed -i '/#vless$/a\#vl '"$user $exp $uuid"'\
},{"id": "'""$uuid""'","email": "'""$user""'"' /etc/xray/config.json
    sed -i '/#vlessgrpc$/a\#vlg '"$user $exp"'\
},{"id": "'""$uuid""'","email": "'""$user""'"' /etc/xray/config.json
    vlesslink1="vless://${uuid}@${domain}:443?path=/vless&security=tls&encryption=none&host=${domain}&type=ws&sni=${domain}#${user}"
    vlesslink2="vless://${uuid}@${domain}:80?path=/vless&security=none&encryption=none&host=${domain}&type=ws#${user}"
    vlesslink3="vless://${uuid}@${domain}:443?mode=gun&security=tls&encryption=none&type=grpc&serviceName=vless-grpc&sni=${domain}#${user}"
    vless1="vless://${uuid}@${domain}:443?path=/vless%26security=tls%26encryption=none%26host=${domain}%26type=ws%26sni=${domain}#${user}"
    vless2="vless://${uuid}@${domain}:80?path=/vless%26security=none%26encryption=none%26host=${domain}%26type=ws#${user}"
    vless3="vless://${uuid}@${domain}:443?mode=gun%26security=tls%26encryption=none%26type=grpc%26serviceName=vless-grpc%26sni=${domain}#${user}"
    clear
    cat >/etc/cron.d/trialvless${user} <<END
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
*/$timer * * * * root /usr/bin/trial vless $user $uuid $exp
END
    cat >/home/vps/public_html/vless-$user.txt <<-END
_______________________________
Format Vless WS (CDN)
_______________________________
- name: vless-$user-WS (CDN)
server: ${domain}
port: 443
type: vless
uuid: ${uuid}
cipher: auto
tls: true
skip-cert-verify: true
servername: ${domain}
network: ws
udp: true
ws-opts:
path: /vless
headers:
Host: ${domain}
_______________________________
Format Vless WS (CDN) Non TLS
_______________________________
- name: vless-$user-WS (CDN) Non TLS
server: ${domain}
port: 80
type: vless
uuid: ${uuid}
cipher: auto
tls: false
skip-cert-verify: false
servername: ${domain}
network: ws
ws-opts:
udp: true
path: /vless
headers:
Host: ${domain}
_______________________________
Format Vless gRPC (SNI)
_______________________________
- name: vless-$user-gRPC (SNI)
server: ${domain}
port: 443
type: vless
uuid: ${uuid}
cipher: auto
tls: true
skip-cert-verify: true
servername: ${domain}
network: grpc
grpc-opts:
grpc-mode: gun
grpc-service-name: vless-grpc
udp: true
_______________________________
Link Vless Account
_______________________________
Link TLS : vless://${uuid}@${domain}:443?path=/vless&security=tls&encryption=none&host=${domain}&type=ws&sni=${domain}#${user}
_______________________________
Link NTLS : vless://${uuid}@${domain}:80?path=/vless&security=none&encryption=none&host=${domain}&type=ws#${user}
_______________________________
Link gRPC : vless://${uuid}@${domain}:443?mode=gun&security=tls&encryption=none&type=grpc&serviceName=vless-grpc&sni=${domain}#${user}
_______________________________
END
    TEXT="
◇━━━━━━━━━━━━━━━━━◇
Trial Premium Vless Account
◇━━━━━━━━━━━━━━━━━◇
User         : ${user}
Domain       : <code>${domain}</code>
Login Limit  : ${iplim} IP
ISP          : ${ISP}
CITY         : ${CITY}
Port TLS     : 443
Port NTLS    : 80, 8080
Port GRPC    : 443
UUID         : <code>${uuid}</code>
AlterId      : 0
Security     : auto
Network      : WS or gRPC
Path vless   : <code>/vless</code>
ServiceName  : <code>/vless-grpc</code>
◇━━━━━━━━━━━━━━━━━◇
Link TLS     :
<code>${vless1}</code>
◇━━━━━━━━━━━━━━━━━◇
Link NTLS    :
<code>${vless2}</code>
◇━━━━━━━━━━━━━━━━━◇
Link GRPC    :
<code>${vless3}</code>
◇━━━━━━━━━━━━━━━━━◇
Format OpenClash :
http://$domain:89/vless-$user.txt
◇━━━━━━━━━━━━━━━━━◇
Expired Until    : $timer Minutes
◇━━━━━━━━━━━━━━━━━◇
$author
◇━━━━━━━━━━━━━━━━━◇
"
    curl -s --max-time $TIMES -d "chat_id=$CHATID&disable_web_page_preview=1&text=$TEXT&parse_mode=html" $URL >/dev/null
    cd
    if [ ! -e /etc/tele ]; then
        echo -ne
    else
        echo "$TEXT" >/etc/notiftele
        bash /etc/tele
    fi
    clear
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}• Trial Premium Vless Account •${NC} $COLOR1 $NC" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}User         ${COLOR1}: ${WH}${user}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}ISP          ${COLOR1}: ${WH}$ISP" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}City         ${COLOR1}: ${WH}$CITY" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Domain       ${COLOR1}: ${WH}${domain}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Login Limit  ${COLOR1}: ${WH}${iplim} IP" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Port TLS     ${COLOR1}: ${WH}443" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Port NTLS    ${COLOR1}: ${WH}80,8080" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Port gRPC    ${COLOR1}: ${WH}443" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}UUID         ${COLOR1}: ${WH}${uuid}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Encryption   ${COLOR1}: ${WH}none" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Network      ${COLOR1}: ${WH}ws" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Path         ${COLOR1}: ${WH}/vless" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Path grpc    ${COLOR1}: ${WH}/vless-grpc" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${COLOR1}Link Websocket TLS      ${WH}:${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}${vlesslink1}${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${COLOR1}Link Websocket NTLS  ${WH}:${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}${vlesslink2}${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${COLOR1}Link gRPC               ${WH}:${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}${vlesslink3}${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Format Openclash ${COLOR1}: " | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}http://$domain:89/vless-$user.txt${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Expired Until   ${COLOR1}: ${WH}$timer Minutes" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}    $author    " | tee -a /etc/vless/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vless/akun/log-create-${user}.log
    echo "" | tee -a /etc/vless/akun/log-create-${user}.log
    systemctl restart xray >/dev/null 2>&1
    read -n 1 -s -r -p "Press any key to back on menu"
    menu
}
function limit-vless() {
    clear
    NUMBER_OF_CLIENTS=$(grep -c -E "^#vlg " "/etc/xray/config.json")
    if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
        clear
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e "$COLOR1 ${NC} ${COLBG1}    ${WH}⇱ Limit Vless Account ⇲     ${NC} $COLOR1 $NC"
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo ""
        echo "You have no existing clients!"
        echo ""
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo ""
        read -n 1 -s -r -p "Press any key to back on menu"
        m-vless
    fi
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo -e "$COLOR1 ${NC} ${COLBG1}    ${WH}⇱ Limit Vless Account ⇲     ${NC} $COLOR1 $NC"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo "Select the existing client you want to change ip"
    echo " ketik [0] kembali kemenu"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo "     No  User   Expired"
    grep -E "^#vlg " "/etc/xray/config.json" | cut -d ' ' -f 2-3 | nl -s ') '
    until [[ ${CLIENT_NUMBER} -ge 1 && ${CLIENT_NUMBER} -le ${NUMBER_OF_CLIENTS} ]]; do
        if [[ ${CLIENT_NUMBER} == '1' ]]; then
            read -rp "Select one client [1]: " CLIENT_NUMBER
        else
            read -rp "Select one client [1-${NUMBER_OF_CLIENTS}]: " CLIENT_NUMBER
            if [[ ${CLIENT_NUMBER} == '0' ]]; then
                m-vless
            fi
        fi
    done
    clear
    until [[ $iplim =~ ^[0-9]+$ ]]; do
        read -p "Limit User (IP) or 0 Unlimited: " iplim
    done
    until [[ $Quota =~ ^[0-9]+$ ]]; do
        read -p "Limit User (GB) or 0 Unlimited: " Quota
    done
    if [ ! -e /etc/vless ]; then
        mkdir -p /etc/vless
    fi
    if [ ${iplim} = '0' ]; then
        iplim="9999"
    fi
    if [ ${Quota} = '0' ]; then
        Quota="9999"
    fi
    user=$(grep -E "^#vlg " "/etc/xray/config.json" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
    c=$(echo "${Quota}" | sed 's/[^0-9]*//g')
    d=$((${c} * 1024 * 1024 * 1024))
    echo "${iplim}" >/etc/vless/${user}IP
    if [[ ${c} != "0" ]]; then
        echo "${d}" >/etc/vless/${user}
    fi
    TEXT="
<code>◇━━━━━━━━━━━━━━◇</code>
<b>  XRAY VLESS IP LIMIT</b>
<code>◇━━━━━━━━━━━━━━◇</code>
<b>DOMAIN   :</b> <code>${domain} </code>
<b>ISP      :</b> <code>$ISP $CITY </code>
<b>USERNAME :</b> <code>$user </code>
<b>IP LIMIT NEW :</b> <code>$iplim IP </code>
<b>QUOTA LIMIT NEW :</b> <code>$Quota GB </code>
<code>◇━━━━━━━━━━━━━━◇</code>
<i>Succes Change IP LIMIT...</i>
"
    curl -s --max-time $TIMES -d "chat_id=$CHATID&disable_web_page_preview=1&text=$TEXT&parse_mode=html" $URL >/dev/null
    cd
    if [ ! -e /etc/tele ]; then
        echo -ne
    else
        echo "$TEXT" >/etc/notiftele
        bash /etc/tele
    fi
    clear
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo " VLESS Account Was Successfully Change Limit IP"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo ""
    echo " Client Name : $user"
    echo " Limit IP    : $iplim IP"
    echo " Limit Quota : $Quota GB"
    echo ""
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo ""
    read -n 1 -s -r -p "Press any key to back on menu"
    m-vless
}
function renew-vless() {
    clear
    NUMBER_OF_CLIENTS=$(grep -c -E "^#vl " "/etc/xray/config.json")
    if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
        clear
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Renew Vless Account ⇲      ${NC} $COLOR1 $NC"
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo ""
        echo "You have no existing clients!"
        echo ""
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo ""
        read -n 1 -s -r -p "Press any key to back on menu"
        m-vless
    fi
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo -e "$COLOR1 ${NC}${COLBG1}     ${WH}⇱ Renew Vless Account ⇲      ${NC} $COLOR1 $NC"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo " Select the existing client you want to renew"
    echo " ketik [0] kembali kemenu"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo "     No  User   Expired"
    grep -E "^#vl " "/etc/xray/config.json" | cut -d ' ' -f 2-3 | nl -s ') '
    until [[ ${CLIENT_NUMBER} -ge 1 && ${CLIENT_NUMBER} -le ${NUMBER_OF_CLIENTS} ]]; do
        if [[ ${CLIENT_NUMBER} == '1' ]]; then
            read -rp "Select one client [1]: " CLIENT_NUMBER
        else
            read -rp "Select one client [1-${NUMBER_OF_CLIENTS}]: " CLIENT_NUMBER
            if [[ ${CLIENT_NUMBER} == '0' ]]; then
                m-vless
            fi
        fi
    done
    read -p "Expired (days): " masaaktif
    user=$(grep -E "^#vl " "/etc/xray/config.json" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
    exp=$(grep -E "^#vl " "/etc/xray/config.json" | cut -d ' ' -f 3 | sed -n "${CLIENT_NUMBER}"p)
    now=$(date +%Y-%m-%d)
    d1=$(date -d "$exp" +%s)
    d2=$(date -d "$now" +%s)
    exp2=$(((d1 - d2) / 86400))
    exp3=$(($exp2 + $masaaktif))
    exp4=$(date -d "$exp3 days" +"%Y-%m-%d")
    sed -i "s/#vl $user $exp/#vl $user $exp4/g" /etc/xray/config.json
    sed -i "s/#vlg $user $exp/#vlg $user $exp4/g" /etc/xray/config.json
    clear
    TEXT="
<code>◇━━━━━━━━━━━━━━◇</code>
<b>   XRAY VLESS RENEW</b>
<code>◇━━━━━━━━━━━━━━◇</code>
<b>DOMAIN   :</b> <code>${domain} </code>
<b>ISP      :</b> <code>$ISP $CITY </code>
<b>USERNAME :</b> <code>$user </code>
<b>EXPIRED  :</b> <code>$exp4 </code>
<code>◇━━━━━━━━━━━━━━◇</code>
"
    curl -s --max-time $TIMES -d "chat_id=$CHATID&disable_web_page_preview=1&text=$TEXT&parse_mode=html" $URL >/dev/null
    cd
    if [ ! -e /etc/tele ]; then
        echo -ne
    else
        echo "$TEXT" >/etc/notiftele
        bash /etc/tele
    fi
    user2=$(echo "$user" | cut -c 1-3)
    TIME2=$(date +'%Y-%m-%d %H:%M:%S')
    TEXT2="
<code>◇━━━━━━━━━━━━━━◇</code>
<b>   PEMBELIAN VLESS SUCCES </b>
<code>◇━━━━━━━━━━━━━━◇</code>
<b>DOMAIN   :</b> <code>${domain} </code>
<b>ISP      :</b> <code>$ISP $CITY </code>
<b>DATE   :</b> <code>${TIME2} WIB </code>
<b>DETAIL   :</b> <code>Trx VLESS </code>
<b>USER :</b> <code>${user2}xxx </code>
<b>DURASI  :</b> <code>$masaaktif Hari </code>
<code>◇━━━━━━━━━━━━━━◇</code>
<i>Renew Account From Server..</i>
"
    curl -s --max-time $TIMES -d "chat_id=$CHATID2&disable_web_page_preview=1&text=$TEXT2&parse_mode=html" $URL2 >/dev/null
    clear
    systemctl restart xray >/dev/null 2>&1
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo " VLESS Account Was Successfully Renewed"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo ""
    echo " Client Name : $user"
    echo " Expired On  : $exp4"
    echo ""
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo ""
    read -n 1 -s -r -p "Press any key to back on menu"
    m-vless
}
function del-vless() {
    clear
    NUMBER_OF_CLIENTS=$(grep -c -E "^#vl " "/etc/xray/config.json")
    if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Delete Vless Account ⇲     ${NC} $COLOR1 $NC"
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo ""
        echo "You have no existing clients!"
        echo ""
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        read -n 1 -s -r -p "Press any key to back on menu"
        m-vless
    fi
    clear
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Delete Vless Account ⇲     ${NC} $COLOR1 $NC"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo ""
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo -e "$COLOR1│ ${WH}Pilih mode delete:                           $COLOR1    │"
    echo -e "$COLOR1│ ${WH}[1] Single User Delete                       $COLOR1    │"
    echo -e "$COLOR1│ ${WH}[2] Multiple Users Delete                    $COLOR1    │"
    echo -e "$COLOR1│ ${WH}[3] Delete All Trial Users                   $COLOR1    │"
    echo -e "$COLOR1│ ${WH}[0] Kembali ke menu                          $COLOR1    │"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    read -rp "Pilih mode [1-3]: " delete_mode

    if [[ $delete_mode == "0" ]]; then
        m-vless
    elif [[ $delete_mode == "1" ]]; then
        # SINGLE USER DELETE
        clear
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Delete Single Vless Account ⇲  ${NC} $COLOR1 $NC"
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo " Select the existing client you want to remove"
        echo " ketik [0] kembali kemenu"
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo "     No  User   Expired"
        grep -E "^#vl " "/etc/xray/config.json" | cut -d ' ' -f 2-3 | nl -s ') '
        until [[ ${CLIENT_NUMBER} -ge 1 && ${CLIENT_NUMBER} -le ${NUMBER_OF_CLIENTS} ]]; do
            if [[ ${CLIENT_NUMBER} == '1' ]]; then
                read -rp "Select one client [1]: " CLIENT_NUMBER
            else
                read -rp "Select one client [1-${NUMBER_OF_CLIENTS}]: " CLIENT_NUMBER
                if [[ ${CLIENT_NUMBER} == '0' ]]; then
                    m-vless
                fi
            fi
        done
        user=$(grep -E "^#vl " "/etc/xray/config.json" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
        exp=$(grep -E "^#vl " "/etc/xray/config.json" | cut -d ' ' -f 3 | sed -n "${CLIENT_NUMBER}"p)
        uuid=$(grep -E "^#vl " "/etc/xray/config.json" | cut -d ' ' -f 4 | sed -n "${CLIENT_NUMBER}"p)

        # Konfirmasi delete
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e " Konfirmasi Delete User: $user"
        echo -e " Expired: $exp"
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        read -rp "Yakin ingin delete user ini? [y/n]: " confirm
        if [[ $confirm =~ ^[Yy]$ ]]; then
            if [ ! -e /etc/vless/akundelete ]; then
                echo "" >/etc/vless/akundelete
            fi
            echo "### $user $exp $uuid" >>/etc/vless/akundelete
            sed -i "/^#vl $user $exp/,/^},{/d" /etc/xray/config.json
            sed -i "/^#vlg $user $exp/,/^},{/d" /etc/xray/config.json
            rm /etc/vless/${user}IP >/dev/null 2>&1
            rm /home/vps/public_html/vless-$user.txt >/dev/null 2>&1
            rm /etc/vless/${user}login >/dev/null 2>&1
            systemctl restart xray >/dev/null 2>&1

            TEXT="
<code>◇━━━━━━━━━━━━━━◇</code>
<b>  XRAY VLESS DELETE</b>
<code>◇━━━━━━━━━━━━━━◇</code>
<b>DOMAIN   :</b> <code>${domain} </code>
<b>ISP      :</b> <code>$ISP $CITY </code>
<b>USERNAME :</b> <code>$user </code>
<b>EXPIRED :</b> <code>$exp </code>
<code>◇━━━━━━━━━━━━━━◇</code>
<i>Succes Delete this Username...</i>
"
            curl -s --max-time $TIMES -d "chat_id=$CHATID&disable_web_page_preview=1&text=$TEXT&parse_mode=html" $URL >/dev/null
            cd
            if [ ! -e /etc/tele ]; then
                echo -ne
            else
                echo "$TEXT" >/etc/notiftele
                bash /etc/tele
            fi
            echo "User $user was removed."
        else
            echo "Delete dibatalkan."
        fi

    elif [[ $delete_mode == "2" ]]; then
        # MULTIPLE USERS DELETE
        clear
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Delete Multiple Vless Users ⇲  ${NC} $COLOR1 $NC"
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo ""
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e " Masukkan nomor user yang ingin didelete"
        echo -e " Contoh: 1,3,5 atau 1-5 atau 1,3-7,9"
        echo -e " ketik 'all' untuk delete semua user"
        echo -e " ketik [0] kembali kemenu"
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo ""
        echo "List Users:"
        grep -E "^#vl " "/etc/xray/config.json" | cut -d ' ' -f 2-3 | nl -s ') '
        echo ""
        read -rp "Masukkan pilihan: " selection

        if [[ $selection == "0" ]]; then
            m-vless
        elif [[ $selection == "all" ]]; then
            # DELETE ALL USERS
            echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
            echo -e " PERINGATAN: Akan mendelete SEMUA user!"
            echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
            read -rp "Yakin ingin delete SEMUA user? ketik 'DELETE ALL' untuk konfirmasi: " confirm_all
            if [[ $confirm_all == "DELETE ALL" ]]; then
                deleted_count=0
                deleted_users=""
                while IFS= read -r line; do
                    if [[ $line =~ ^#vl\ (.*)\ (.*)\ (.*)$ ]]; then
                        user="${BASH_REMATCH[1]}"
                        exp="${BASH_REMATCH[2]}"
                        uuid="${BASH_REMATCH[3]}"
                        # Delete user
                        if [ ! -e /etc/vless/akundelete ]; then
                            echo "" >/etc/vless/akundelete
                        fi
                        echo "### $user $exp $uuid" >>/etc/vless/akundelete
                        sed -i "/^#vl $user $exp/,/^},{/d" /etc/xray/config.json
                        sed -i "/^#vlg $user $exp/,/^},{/d" /etc/xray/config.json
                        rm /etc/vless/${user}IP >/dev/null 2>&1
                        rm /home/vps/public_html/vless-$user.txt >/dev/null 2>&1
                        rm /etc/vless/${user}login >/dev/null 2>&1
                        deleted_count=$((deleted_count + 1))
                        deleted_users="$deleted_users$user, "
                    fi
                done < <(grep -E "^#vl " "/etc/xray/config.json")

                systemctl restart xray >/dev/null 2>&1
                deleted_users=${deleted_users%, }
                echo "Berhasil delete $deleted_count users: $deleted_users"

                # Send telegram notification
                TEXT="
<code>◇━━━━━━━━━━━━━━◇</code>
<b>  BULK DELETE VLESS USERS</b>
<code>◇━━━━━━━━━━━━━━◇</code>
<b>DOMAIN   :</b> <code>${domain} </code>
<b>ISP      :</b> <code>$ISP $CITY </code>
<b>DELETED  :</b> <code>$deleted_count users</code>
<b>USERS    :</b> <code>$deleted_users</code>
<code>◇━━━━━━━━━━━━━━◇</code>
<i>Bulk Delete Users Success...</i>
"
                curl -s --max-time $TIMES -d "chat_id=$CHATID&disable_web_page_preview=1&text=$TEXT&parse_mode=html" $URL >/dev/null
            else
                echo "Delete dibatalkan."
            fi
        else
            # PARSE SELECTION AND DELETE SELECTED USERS
            selected_numbers=()
            IFS=',' read -ra ADDR <<< "$selection"
            for i in "${ADDR[@]}"; do
                if [[ $i =~ ^([0-9]+)-([0-9]+)$ ]]; then
                    start=${BASH_REMATCH[1]}
                    end=${BASH_REMATCH[2]}
                    for ((j=start; j<=end; j++)); do
                        if [[ $j -ge 1 && $j -le $NUMBER_OF_CLIENTS ]]; then
                            selected_numbers+=($j)
                        fi
                    done
                elif [[ $i =~ ^[0-9]+$ ]]; then
                    if [[ $i -ge 1 && $i -le $NUMBER_OF_CLIENTS ]]; then
                        selected_numbers+=($i)
                    fi
                fi
            done

            selected_numbers=($(printf '%s\n' "${selected_numbers[@]}" | sort -nu))

            if [[ ${#selected_numbers[@]} -eq 0 ]]; then
                echo "Tidak ada nomor yang valid dipilih."
            else
                echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
                echo -e " User yang akan didelete:"
                echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
                users_to_delete=""
                for num in "${selected_numbers[@]}"; do
                    user=$(grep -E "^#vl " "/etc/xray/config.json" | cut -d ' ' -f 2 | sed -n "${num}p")
                    exp=$(grep -E "^#vl " "/etc/xray/config.json" | cut -d ' ' -f 3 | sed -n "${num}p")
                    echo "$num) $user ($exp)"
                    users_to_delete="$users_to_delete$user, "
                done
                users_to_delete=${users_to_delete%, }

                echo ""
                read -rp "Yakin ingin delete ${#selected_numbers[@]} users ini? [y/n]: " confirm_multi
                if [[ $confirm_multi =~ ^[Yy]$ ]]; then
                    deleted_count=0
                    deleted_users=""
                    for ((i=${#selected_numbers[@]}-1; i>=0; i--)); do
                        num=${selected_numbers[i]}
                        user=$(grep -E "^#vl " "/etc/xray/config.json" | cut -d ' ' -f 2 | sed -n "${num}p")
                        exp=$(grep -E "^#vl " "/etc/xray/config.json" | cut -d ' ' -f 3 | sed -n "${num}p")
                        uuid=$(grep -E "^#vl " "/etc/xray/config.json" | cut -d ' ' -f 4 | sed -n "${num}p")

                        if [ ! -e /etc/vless/akundelete ]; then
                            echo "" >/etc/vless/akundelete
                        fi
                        echo "### $user $exp $uuid" >>/etc/vless/akundelete
                        sed -i "/^#vl $user $exp/,/^},{/d" /etc/xray/config.json
                        sed -i "/^#vlg $user $exp/,/^},{/d" /etc/xray/config.json
                        rm /etc/vless/${user}IP >/dev/null 2>&1
                        rm /home/vps/public_html/vless-$user.txt >/dev/null 2>&1
                        rm /etc/vless/${user}login >/dev/null 2>&1
                        echo "User $user was removed."
                        deleted_count=$((deleted_count + 1))
                        deleted_users="$user, $deleted_users"
                    done

                    systemctl restart xray >/dev/null 2>&1
                    deleted_users=${deleted_users%, }
                    echo "Berhasil delete $deleted_count users: $deleted_users"

                    # Send telegram notification
                    TEXT="
<code>◇━━━━━━━━━━━━━━◇</code>
<b>  BULK DELETE VLESS USERS</b>
<code>◇━━━━━━━━━━━━━━◇</code>
<b>DOMAIN   :</b> <code>${domain} </code>
<b>ISP      :</b> <code>$ISP $CITY </code>
<b>DELETED  :</b> <code>$deleted_count users</code>
<b>USERS    :</b> <code>$deleted_users</code>
<code>◇━━━━━━━━━━━━━━◇</code>
<i>Bulk Delete Users Success...</i>
"
                    curl -s --max-time $TIMES -d "chat_id=$CHATID&disable_web_page_preview=1&text=$TEXT&parse_mode=html" $URL >/dev/null
                    cd
                    if [ ! -e /etc/tele ]; then
                        echo -ne
                    else
                        echo "$TEXT" >/etc/notiftele
                        bash /etc/tele
                    fi
                else
                    echo "Delete dibatalkan."
                fi
            fi
        fi

    elif [[ $delete_mode == "3" ]]; then
        # DELETE ALL TRIAL USERS
        clear
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Delete All Trial Vless Users ⇲  ${NC} $COLOR1 $NC"
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo ""

        # Count trial users
        trial_count=$(grep -E "^#vl trial-" "/etc/xray/config.json" | wc -l)

        if [[ $trial_count -eq 0 ]]; then
            echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
            echo -e " Tidak ada user trial vless yang ditemukan!"
            echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
            echo ""
            read -n 1 -s -r -p "Press any key to back on menu"
            m-vless
        fi

        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e " Ditemukan $trial_count user trial vless:"
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo ""
        echo "List Trial Vless Users:"
        grep -E "^#vl trial-" "/etc/xray/config.json" | cut -d ' ' -f 2-3 | nl -s ') '
        echo ""

        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e " PERINGATAN: Akan mendelete SEMUA user trial vless!"
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        read -rp "Yakin ingin delete semua user trial vless? ketik 'DELETE TRIAL' untuk konfirmasi: " confirm_trial

        if [[ $confirm_trial == "DELETE TRIAL" ]]; then
            deleted_count=0
            deleted_users=""

            # Get all trial users and delete them
            while IFS= read -r line; do
                if [[ $line =~ ^#vl\ (trial-.*)\ (.*)\ (.*)$ ]]; then
                    user="${BASH_REMATCH[1]}"
                    exp="${BASH_REMATCH[2]}"
                    uuid="${BASH_REMATCH[3]}"

                    # Delete user from VLESS
                    if [ ! -e /etc/vless/akundelete ]; then
                        echo "" >/etc/vless/akundelete
                    fi
                    echo "### $user $exp $uuid" >>/etc/vless/akundelete
                    sed -i "/^#vl $user $exp/,/^},{/d" /etc/xray/config.json
                    sed -i "/^#vlg $user $exp/,/^},{/d" /etc/xray/config.json

                    # Clean up files
                    rm /etc/vless/${user}IP >/dev/null 2>&1
                    rm /home/vps/public_html/vless-$user.txt >/dev/null 2>&1
                    rm /etc/vless/${user}login >/dev/null 2>&1
                    rm /etc/vless/akun/log-create-${user}.log >/dev/null 2>&1

                    # Cancel any pending cron jobs for this trial user
                    rm /etc/cron.d/trialvless${user} >/dev/null 2>&1

                    deleted_count=$((deleted_count + 1))
                    deleted_users="$deleted_users$user, "

                    echo "User trial vless $user berhasil dihapus."
                fi
            done < <(grep -E "^#vl trial-" "/etc/xray/config.json")

            # Restart Xray service
            systemctl restart xray >/dev/null 2>&1

            deleted_users=${deleted_users%, }  # Remove trailing comma
            echo ""
            echo "Berhasil menghapus $deleted_count user trial vless: $deleted_users"

            # Send telegram notification
            TEXT="
<code>◇━━━━━━━━━━━━━━◇</code>
<b>  DELETE ALL TRIAL VLESS USERS</b>
<code>◇━━━━━━━━━━━━━━◇</code>
<b>DOMAIN   :</b> <code>${domain} </code>
<b>ISP      :</b> <code>$ISP $CITY </code>
<b>DELETED  :</b> <code>$deleted_count trial vless users</code>
<b>USERS    :</b> <code>$deleted_users</code>
<code>◇━━━━━━━━━━━━━━◇</code>
<i>All Trial Vless Users Deleted Successfully...</i>
"
            curl -s --max-time $TIMES -d "chat_id=$CHATID&disable_web_page_preview=1&text=$TEXT&parse_mode=html" $URL >/dev/null
            cd
            if [ ! -e /etc/tele ]; then
                echo -ne
            else
                echo "$TEXT" >/etc/notiftele
                bash /etc/tele
            fi
        else
            echo "Delete trial vless users dibatalkan."
        fi

    else
        echo "Pilihan tidak valid."
        sleep 1
        del-vless
    fi

    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo ""
    read -n 1 -s -r -p "Press any key to back on menu"
    m-vless
}
tim2sec() {
    mult=1
    arg="$1"
    inu=0
    while [ ${#arg} -gt 0 ]; do
        prev="${arg%:*}"
        if [ "$prev" = "$arg" ]; then
            curr="${arg#0}"
            prev=""
        else
            curr="${arg##*:}"
            curr="${curr#0}"
        fi
        curr="${curr%.*}"
        inu=$((inu + curr * mult))
        mult=$((mult * 60))
        arg="$prev"
    done
    echo "$inu"
}
function convert() {
    local -i bytes=$1
    if [[ $bytes -lt 1024 ]]; then
        echo "${bytes} B"
    elif [[ $bytes -lt 1048576 ]]; then
        echo "$(((bytes + 1023) / 1024)) KB"
    elif [[ $bytes -lt 1073741824 ]]; then
        echo "$(((bytes + 1048575) / 1048576)) MB"
    else
        echo "$(((bytes + 1073741823) / 1073741824)) GB"
    fi
}
function cek-vless() {
    clear
    xrayy=$(cat /var/log/xray/access.log | wc -l)
    if [[ xrayy -le 5 ]]; then
        systemctl restart xray
    fi
    xraylimit
    echo -e "$COLOR1╭═════════════════════════════════════════════════╮${NC}"
    echo -e "$COLOR1│${NC} ${COLBG1}            ${WH}• VLESS USER ONLINE •              ${NC} $COLOR1│ $NC"
    echo -e "$COLOR1╰═════════════════════════════════════════════════╯${NC}"
    echo -e "$COLOR1╭═════════════════════════════════════════════════╮${NC}"
    vm=($(cat /etc/xray/config.json | grep "^#vlg" | awk '{print $2}' | sort -u))
    echo -n >/tmp/vm
    for db1 in ${vm[@]}; do
        logvm=$(cat /var/log/xray/access.log | grep -w "email: ${db1}" | tail -n 100)
        while read a; do
            if [[ -n ${a} ]]; then
                set -- ${a}
                ina="${7}"
                inu="${2}"
                anu="${3}"
                enu=$(echo "${anu}" | sed 's/tcp://g' | sed '/^$/d' | cut -d. -f1,2,3)
                now=$(tim2sec ${timenow})
                client=$(tim2sec ${inu})
                nowt=$(((${now} - ${client})))
                if [[ ${nowt} -lt 40 ]]; then
                    cat /tmp/vm | grep -w "${ina}" | grep -w "${enu}" >/dev/null
                    if [[ $? -eq 1 ]]; then
                        echo "${ina} ${inu} WIB : ${enu}" >>/tmp/vm
                        splvm=$(cat /tmp/vm)
                    fi
                fi
            fi
        done <<<"${logvm}"
    done
    if [[ ${splvm} != "" ]]; then
        for vmuser in ${vm[@]}; do
            vmhas=$(cat /tmp/vm | grep -w "${vmuser}" | wc -l)
            tess=0
            if [[ ${vmhas} -gt $tess ]]; then
                byt=$(cat /etc/limit/vless/${vmuser})
                gb=$(convert ${byt})
                lim=$(cat /etc/vless/${vmuser})
                lim2=$(convert ${lim})
                echo -e "$COLOR1${NC} USERNAME : \033[0;33m$vmuser"
                echo -e "$COLOR1${NC} IP LOGIN : \033[0;33m$vmhas"
                echo -e "$COLOR1${NC} USAGE : \033[0;33m$gb"
                echo -e "$COLOR1${NC} LIMIT : \033[0;33m$lim2"
                echo -e ""
            fi
        done
    fi
    echo -e "$COLOR1╰═════════════════════════════════════════════════╯${NC}"
    echo ""
    read -n 1 -s -r -p "   Press any key to back on menu"
    m-vless
}
function list-vless() {
    clear
    NUMBER_OF_CLIENTS=$(grep -c -E "^#vl " "/etc/xray/config.json")
    if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Config Vless Account ⇲     ${NC} $COLOR1 $NC"
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo ""
        echo "You have no existing clients!"
        echo ""
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        read -n 1 -s -r -p "Press any key to back on menu"
        m-vless
    fi
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Config Vless Account ⇲     ${NC} $COLOR1 $NC"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo " Select the existing client to view the config"
    echo " ketik [0] kembali kemenu"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\033[0m"
    echo "     No  User   Expired"
    grep -E "^#vl " "/etc/xray/config.json" | cut -d ' ' -f 2-3 | nl -s ') '
    until [[ ${CLIENT_NUMBER} -ge 1 && ${CLIENT_NUMBER} -le ${NUMBER_OF_CLIENTS} ]]; do
        if [[ ${CLIENT_NUMBER} == '1' ]]; then
            read -rp "Select one client [1]: " CLIENT_NUMBER
        else
            read -rp "Select one client [1-${NUMBER_OF_CLIENTS}]: " CLIENT_NUMBER
            if [[ ${CLIENT_NUMBER} == '0' ]]; then
                m-vless
            fi
        fi
    done
    clear
    user=$(grep -E "^#vl " "/etc/xray/config.json" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
    cat /etc/vless/akun/log-create-${user}.log
    cat /etc/vless/akun/log-create-${user}.log >/etc/notifakun
    sed -i 's/\x1B\[1;37m//g' /etc/notifakun
    sed -i 's/\x1B\[0;96m//g' /etc/notifakun
    sed -i 's/\x1B\[0m//g' /etc/notifakun
    TEXT=$(cat /etc/notifakun)
    curl -s --max-time $TIMES -d "chat_id=$CHATID&disable_web_page_preview=1&text=$TEXT&parse_mode=html" $URL >/dev/null
    cd
    if [ ! -e /etc/tele ]; then
        echo -ne
    else
        echo "$TEXT" >/etc/notiftele
        bash /etc/tele
    fi
    read -n 1 -s -r -p "Press any key to back on menu"
    m-vless
}
function login-vless() {
    clear
    echo -e "$COLOR1╭═══════════════════════════════════════════════╮${NC}"
    echo -e "$COLOR1│${NC} ${COLBG1}          ${WH}• SETTING MULTI LOGIN •            ${NC} $COLOR1│ $NC"
    echo -e "$COLOR1╰═══════════════════════════════════════════════╯${NC}"
    echo -e "$COLOR1╭═══════════════════════════════════════════════╮${NC}"
    echo -e "${COLOR1}│ $NC SILAHKAN TULIS JUMLAH NOTIFIKASI UNTUK LOCK    ${NC}"
    echo -e "${COLOR1}│ $NC AKUN USER YANG MULTI LOGIN     ${NC}"
    echo -e "$COLOR1╰═══════════════════════════════════════════════╯${NC}"
    read -rp "   Jika Mau 3x Notif baru kelock tulis 3, dst: " -e notif
    cd /etc/vless
    echo "$notif" >notif
    clear
    echo -e "$COLOR1╭═══════════════════════════════════════════════╮${NC}"
    echo -e "$COLOR1│${NC} ${COLBG1}          ${WH}• SETTING MULTI LOGIN •            ${NC} $COLOR1│ $NC"
    echo -e "$COLOR1╰═══════════════════════════════════════════════╯${NC}"
    echo -e "$COLOR1╭═══════════════════════════════════════════════╮${NC}"
    echo -e "${COLOR1}│ $NC SUCCES GANTI NOTIF LOCK JADI $notif $NC "
    echo -e "$COLOR1╰═══════════════════════════════════════════════╯${NC}"
    m-vless
}
function lock-vless() {
    cd
    clear
    if [ ! -e /etc/vless/listlock ]; then
        echo "" >/etc/vless/listlock
    fi
    NUMBER_OF_CLIENTS=$(grep -c -E "^### " "/etc/vless/listlock")
    if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Unlock Vless Account ⇲     ${NC} $COLOR1 $NC"
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo ""
        echo "You have no existing user Lock!"
        echo ""
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        read -n 1 -s -r -p "Press any key to back on menu"
        m-vless
    fi
    clear
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Unlock Vless Account ⇲     ${NC} $COLOR1 $NC"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo " Select the existing client you want to Unlock"
    echo " ketik [0] kembali kemenu"
    echo " ketik [999] untuk delete semua Akun"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo "     No  User   Expired"
    grep -E "^### " "/etc/vless/listlock" | cut -d ' ' -f 2-3 | nl -s ') '
    until [[ ${CLIENT_NUMBER} -ge 1 && ${CLIENT_NUMBER} -le ${NUMBER_OF_CLIENTS} ]]; do
        if [[ ${CLIENT_NUMBER} == '1' ]]; then
            read -rp "Select one client [1]: " CLIENT_NUMBER
        else
            read -rp "Select one client [1-${NUMBER_OF_CLIENTS}] to Unlock: " CLIENT_NUMBER
            if [[ ${CLIENT_NUMBER} == '0' ]]; then
                m-vless
            fi
            if [[ ${CLIENT_NUMBER} == '999' ]]; then
                rm /etc/vless/listlock
                m-vless
            fi
        fi
    done
    user=$(grep -E "^### " "/etc/vless/listlock" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
    exp=$(grep -E "^### " "/etc/vless/listlock" | cut -d ' ' -f 3 | sed -n "${CLIENT_NUMBER}"p)
    uuid=$(grep -E "^### " "/etc/vless/listlock" | cut -d ' ' -f 4 | sed -n "${CLIENT_NUMBER}"p)
    sed -i '/#vless$/a\#vl '"$user $exp $uuid"'\
},{"id": "'""$uuid""'","email": "'""$user""'"' /etc/xray/config.json
    sed -i '/#vlessgrpc$/a\#vlg '"$user $exp"'\
},{"id": "'""$uuid""'","email": "'""$user""'"' /etc/xray/config.json
    sed -i "/^### $user $exp $uuid/d" /etc/vless/listlock
    systemctl restart xray
    TEXT="
<code>◇━━━━━━━━━━━━━━◇</code>
<b>  XRAY VLESS UNLOCKED</b>
<code>◇━━━━━━━━━━━━━━◇</code>
<b>DOMAIN   :</b> <code>${domain} </code>
<b>ISP      :</b> <code>$ISP $CITY </code>
<b>USERNAME :</b> <code>$user </code>
<b>EXPIRED  :</b> <code>$exp </code>
<code>◇━━━━━━━━━━━━━━◇</code>
<i>Succes Unlocked This Akun...</i>
"
    curl -s --max-time $TIMES -d "chat_id=$CHATID&disable_web_page_preview=1&text=$TEXT&parse_mode=html" $URL >/dev/null
    cd
    if [ ! -e /etc/tele ]; then
        echo -ne
    else
        echo "$TEXT" >/etc/notiftele
        bash /etc/tele
    fi
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo " Vless Account Unlock Successfully"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo " Client Name : $user"
    echo " Status  : Unlocked"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo ""
    read -n 1 -s -r -p "Press any key to back on menu"
    m-vless
}
function res-user() {
    clear
    cd
    if [ ! -e /etc/vless/akundelete ]; then
        echo "" >/etc/vless/akundelete
    fi
    clear
    NUMBER_OF_CLIENTS=$(grep -c -E "^### " "/etc/vless/akundelete")
    if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Restore Vless Account ⇲    ${NC} $COLOR1 $NC"
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo ""
        echo "You have no existing user Expired!"
        echo ""
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        read -n 1 -s -r -p "Press any key to back on menu"
        m-vless
    fi
    clear
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Restore Vless Account ⇲    ${NC} $COLOR1 $NC"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo " Select the existing client you want to Restore"
    echo " ketik [0] kembali kemenu"
    echo " ketik [999] untuk delete semua Akun"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo "     No  User   Expired"
    grep -E "^### " "/etc/vless/akundelete" | cut -d ' ' -f 2-3 | nl -s ') '
    until [[ ${CLIENT_NUMBER} -ge 1 && ${CLIENT_NUMBER} -le ${NUMBER_OF_CLIENTS} ]]; do
        if [[ ${CLIENT_NUMBER} == '1' ]]; then
            read -rp "Select one client [1]: " CLIENT_NUMBER
        else
            read -rp "Select one client [1-${NUMBER_OF_CLIENTS}] to Unlock: " CLIENT_NUMBER
            if [[ ${CLIENT_NUMBER} == '0' ]]; then
                m-vless
            fi
            if [[ ${CLIENT_NUMBER} == '999' ]]; then
                rm /etc/vless/akundelete
                m-vless
            fi
        fi
    done
    until [[ $masaaktif =~ ^[0-9]+$ ]]; do
        read -p "Expired (days): " masaaktif
    done
    until [[ $iplim =~ ^[0-9]+$ ]]; do
        read -p "Limit User (IP) or 0 Unlimited: " iplim
    done
    until [[ $Quota =~ ^[0-9]+$ ]]; do
        read -p "Limit Quota (GB) or 0 Unlimited: " Quota
    done
    if [ ${iplim} = '0' ]; then
        iplim="9999"
    fi
    if [ ${Quota} = '0' ]; then
        Quota="9999"
    fi
    user=$(grep -E "^### " "/etc/vless/akundelete" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
    exp=$(date -d "$masaaktif days" +"%Y-%m-%d")
    uuid=$(grep -E "^### " "/etc/vless/akundelete" | cut -d ' ' -f 4 | sed -n "${CLIENT_NUMBER}"p)
    sed -i '/#vless$/a\#vl '"$user $exp $uuid"'\
},{"id": "'""$uuid""'","email": "'""$user""'"' /etc/xray/config.json
    sed -i '/#vlessgrpc$/a\#vlg '"$user $exp"'\
},{"id": "'""$uuid""'","email": "'""$user""'"' /etc/xray/config.json
    echo "${iplim}" >/etc/vless/${user}IP
    c=$(echo "${Quota}" | sed 's/[^0-9]*//g')
    d=$((${c} * 1024 * 1024 * 1024))
    if [[ ${c} != "0" ]]; then
        echo "${d}" >/etc/vless/${user}
    fi
    sed -i "/^### ${user} ${exp} ${uuid}/d" /etc/vless/akundelete
    systemctl restart xray
    TEXT="
<code>◇━━━━━━━━━━━━━━◇</code>
<b>  XRAY VLESS RESTORE</b>
<code>◇━━━━━━━━━━━━━━◇</code>
<b>DOMAIN   :</b> <code>${domain} </code>
<b>ISP      :</b> <code>$ISP $CITY </code>
<b>USERNAME :</b> <code>$user </code>
<b>IP LIMIT  :</b> <code>$iplim IP </code>
<b>Quota LIMIT  :</b> <code>$Quota GB </code>
<b>EXPIRED  :</b> <code>$exp </code>
<code>◇━━━━━━━━━━━━━━◇</code>
<i>Succes Restore This Akun...</i>
"
    curl -s --max-time $TIMES -d "chat_id=$CHATID&disable_web_page_preview=1&text=$TEXT&parse_mode=html" $URL >/dev/null
    cd
    if [ ! -e /etc/tele ]; then
        echo -ne
    else
        echo "$TEXT" >/etc/notiftele
        bash /etc/tele
    fi
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo " Vless Account Restore Successfully"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo " Client Name : $user"
    echo " Expired  : $exp"
    echo " Succes to Restore"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo ""
    read -n 1 -s -r -p "Press any key to back on menu"
    m-vless
}
function quota-user() {
    cd
    clear
    if [ ! -e /etc/vless/userQuota ]; then
        echo "" >/etc/vless/userQuota
    fi
    NUMBER_OF_CLIENTS=$(grep -c -E "^### " "/etc/vless/userQuota")
    if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Unlock Vless Account ⇲     ${NC} $COLOR1 $NC"
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo ""
        echo "You have no existing user Lock!"
        echo ""
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        read -n 1 -s -r -p "Press any key to back on menu"
        m-vless
    fi
    clear
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Unlock Vless Account ⇲     ${NC} $COLOR1 $NC"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo " Select the existing client you want to Unlock"
    echo " ketik [0] kembali kemenu"
    echo " ketik [999] untuk delete semua Akun"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo "     No  User   Expired"
    grep -E "^### " "/etc/vless/userQuota" | cut -d ' ' -f 2-3 | nl -s ') '
    until [[ ${CLIENT_NUMBER} -ge 1 && ${CLIENT_NUMBER} -le ${NUMBER_OF_CLIENTS} ]]; do
        if [[ ${CLIENT_NUMBER} == '1' ]]; then
            read -rp "Select one client [1]: " CLIENT_NUMBER
        else
            read -rp "Select one client [1-${NUMBER_OF_CLIENTS}] to Unlock: " CLIENT_NUMBER
            if [[ ${CLIENT_NUMBER} == '0' ]]; then
                m-vless
            fi
            if [[ ${CLIENT_NUMBER} == '999' ]]; then
                rm /etc/vless/userQuota
                m-vless
            fi
        fi
    done
    user=$(grep -E "^### " "/etc/vless/userQuota" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
    exp=$(grep -E "^### " "/etc/vless/userQuota" | cut -d ' ' -f 3 | sed -n "${CLIENT_NUMBER}"p)
    uuid=$(grep -E "^### " "/etc/vless/userQuota" | cut -d ' ' -f 4 | sed -n "${CLIENT_NUMBER}"p)
    sed -i '/#vless$/a\#vl '"$user $exp $uuid"'\
},{"id": "'""$uuid""'","email": "'""$user""'"' /etc/xray/config.json
    sed -i '/#vlessgrpc$/a\#vlg '"$user $exp"'\
},{"id": "'""$uuid""'","email": "'""$user""'"' /etc/xray/config.json
    sed -i "/^### $user $exp $uuid/d" /etc/vless/userQuota
    systemctl restart xray
    TEXT="
<code>◇━━━━━━━━━━━━━━◇</code>
<b>  XRAY VLESS UNLOCKED</b>
<code>◇━━━━━━━━━━━━━━◇</code>
<b>DOMAIN   :</b> <code>${domain} </code>
<b>ISP      :</b> <code>$ISP $CITY </code>
<b>USERNAME :</b> <code>$user </code>
<b>EXPIRED  :</b> <code>$exp </code>
<code>◇━━━━━━━━━━━━━━◇</code>
<i>Succes Unlocked This Akun...</i>
"
    curl -s --max-time $TIMES -d "chat_id=$CHATID&disable_web_page_preview=1&text=$TEXT&parse_mode=html" $URL >/dev/null
    cd
    if [ ! -e /etc/tele ]; then
        echo -ne
    else
        echo "$TEXT" >/etc/notiftele
        bash /etc/tele
    fi
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo " Vless Account Unlock Successfully"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo " Client Name : $user"
    echo " Status  : Unlocked"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo ""
    read -n 1 -s -r -p "Press any key to back on menu"
    m-vless
}
clear
author=$(cat /etc/profil)
echo -e " $COLOR1╭════════════════════════════════════════════════════╮${NC}"
echo -e " $COLOR1│${NC} ${COLBG1}            ${WH}• VLESS PANEL MENU •                  ${NC} $COLOR1│ $NC"
echo -e " $COLOR1╰════════════════════════════════════════════════════╯${NC}"
echo -e " $COLOR1╭════════════════════════════════════════════════════╮${NC}"
echo -e " $COLOR1│ $NC ${WH}[${COLOR1}01${WH}]${NC} ${COLOR1}• ${WH}ADD AKUN${NC}         ${WH}[${COLOR1}06${WH}]${NC} ${COLOR1}• ${WH}CEK USER CONFIG${NC}    $COLOR1│ $NC"
echo -e " $COLOR1│ $NC ${WH}[${COLOR1}02${WH}]${NC} ${COLOR1}• ${WH}TRIAL AKUN${NC}       ${WH}[${COLOR1}07${WH}]${NC} ${COLOR1}• ${WH}CHANGE USER LIMIT${NC}  $COLOR1│ $NC"
echo -e " $COLOR1│ $NC ${WH}[${COLOR1}03${WH}]${NC} ${COLOR1}• ${WH}RENEW AKUN${NC}       ${WH}[${COLOR1}08${WH}]${NC} ${COLOR1}• ${WH}SETTING LOCK LOGIN${NC} $COLOR1│ $NC"
echo -e " $COLOR1│ $NC ${WH}[${COLOR1}04${WH}]${NC} ${COLOR1}• ${WH}DELETE AKUN${NC}      ${WH}[${COLOR1}09${WH}]${NC} ${COLOR1}• ${WH}UNLOCK USER LOGIN${NC}  $COLOR1│ $NC"
echo -e " $COLOR1│ $NC ${WH}[${COLOR1}05${WH}]${NC} ${COLOR1}• ${WH}CEK USER LOGIN${NC}   ${WH}[${COLOR1}10${WH}]${NC} ${COLOR1}• ${WH}UNLOCK USER QUOTA ${NC} $COLOR1│ $NC"
echo -e " $COLOR1│ $NC ${WH}[${COLOR1}00${WH}]${NC} ${COLOR1}• ${WH}GO BACK${NC}          ${WH}[${COLOR1}11${WH}]${NC} ${COLOR1}• ${WH}RESTORE AKUN   ${NC}    $COLOR1│ $NC"
echo -e " $COLOR1╰════════════════════════════════════════════════════╯${NC}"
echo -e " $COLOR1╭═════════════════════════ ${WH}BY${NC} ${COLOR1}═══════════════════════╮ ${NC}"
printf "                      ${COLOR1}%3s${NC} ${WH}%0s${NC} ${COLOR1}%3s${NC}\n" "• " "$author" " •"
echo -e " $COLOR1╰════════════════════════════════════════════════════╯${NC}"
echo -e ""
echo -ne " ${WH}Select menu ${COLOR1}: ${WH}"
read opt
case $opt in
1)
    clear
    add-vless
    exit
    ;;
2)
    clear
    trial-vless
    exit
    ;;
3)
    clear
    renew-vless
    exit
    ;;
4)
    clear
    del-vless
    exit
    ;;
5)
    clear
    cek-vless
    exit
    ;;
6)
    clear
    list-vless
    exit
    ;;
7)
    clear
    limit-vless
    exit
    ;;
8)
    clear
    login-vless
    exit
    ;;
9)
    clear
    lock-vless
    exit
    ;;
10)
    clear
    quota-user
    exit
    ;;
11)
    clear
    res-user
    exit
    ;;
0)
    clear
    menu
    exit
    ;;
x) exit ;;
*)
    echo "salah tekan "
    sleep 1
    m-vless
    ;;
esac
