#!/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
cd
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/vmess/akun ]; then
    mkdir -p /etc/vmess/akun
fi
function add-vmess() {
    clear
    until [[ $user =~ ^[a-zA-Z0-9_.-]+$ && ${CLIENT_EXISTS} == '0' ]]; do
        echo -e "$COLOR1╭═════════════════════════════════════════════════╮${NC}"
        echo -e "$COLOR1│${NC} ${COLBG1}            ${WH}• Add Vmess Account •              ${NC} $COLOR1│ $NC"
        echo -e "$COLOR1╰═════════════════════════════════════════════════╯${NC}"
        echo -e ""
        read -rp "  Username    : " -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 Vmess 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-vmess
        fi
    done
    exp=$(date -d "$masaaktif days" +"%Y-%m-%d")
    until [[ $iplim =~ ^[0-9]+$ ]]; do
        read -p "  Limit User  : " iplim
    done
    until [[ $Quota =~ ^[0-9]+$ ]]; do
        read -p "  Limit Quota : " Quota
    done
    uuid=$(cat /proc/sys/kernel/random/uuid)
    until [[ $masaaktif =~ ^[0-9]+$ ]]; do
        read -p "  Masa Aktif  : " masaaktif
    done
    if [ ! -e /etc/vmess ]; then
        mkdir -p /etc/vmess
    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/vmess/${user}
    fi
    echo "${iplim}" >/etc/vmess/${user}IP
    exp=$(date -d "$masaaktif days" +"%Y-%m-%d")
    sed -i '/#vmess$/a\#vm '"$user $exp"'\
},{"id": "'""$uuid""'","alterId": '"0"',"email": "'""$user""'"' /etc/xray/config.json
    sed -i '/#vmessgrpc$/a\#vmg '"$user $exp $uuid"'\
},{"id": "'""$uuid""'","alterId": '"0"',"email": "'""$user""'"' /etc/xray/config.json
    asu=$(cat <<EOF
{
"v": "2",
"ps": "${user}",
"add": "${domain}",
"port": "443",
"id": "${uuid}",
"aid": "0",
"net": "ws",
"path": "/vmess",
"type": "none",
"host": "${domain}",
"tls": "tls"
}
EOF
    )
    ask=$(cat <<EOF
{
"v": "2",
"ps": "${user}",
"add": "${domain}",
"port": "80",
"id": "${uuid}",
"aid": "0",
"net": "ws",
"path": "/vmess",
"type": "none",
"host": "${domain}",
"tls": "none"
}
EOF
    )
    grpc=$(cat <<EOF
{
"v": "2",
"ps": "${user}",
"add": "${domain}",
"port": "443",
"id": "${uuid}",
"aid": "0",
"net": "grpc",
"path": "vmess-grpc",
"type": "none",
"host": "${domain}",
"tls": "tls"
}
EOF
    )
    vmess_base641=$(base64 -w 0 <<<$vmess_json1)
    vmess_base642=$(base64 -w 0 <<<$vmess_json2)
    vmess_base643=$(base64 -w 0 <<<$vmess_json3)
    vmesslink1="vmess://$(echo $asu | base64 -w 0)"
    vmesslink2="vmess://$(echo $ask | base64 -w 0)"
    vmesslink3="vmess://$(echo $grpc | base64 -w 0)"
    VMESS_WS=$(cat <<EOF
{
"v": "2",
"ps": "${user}",
"add": "${domain}",
"port": "443",
"id": "${uuid}",
"aid": "0",
"net": "ws",
"path": "/vmess",
"type": "none",
"host": "${domain}",
"tls": "tls"
}
EOF
    )
    VMESS_NON_TLS=$(cat <<EOF
{
"v": "2",
"ps": "${user}",
"add": "${domain}",
"port": "80",
"id": "${uuid}",
"aid": "0",
"net": "ws",
"path": "/vmess",
"type": "none",
"host": "${domain}",
"tls": "none"
}
EOF
    )
    VMESS_GRPC=$(cat <<EOF
{
"v": "2",
"ps": "${user}",
"add": "${domain}",
"port": "443",
"id": "${uuid}",
"aid": "0",
"net": "grpc",
"path": "/vmess-grpc",
"type": "none",
"host": "${domain}",
"tls": "tls"
}
EOF
    )
    VMESS_OPOK=$(cat <<EOF
{
"v": "2",
"ps": "${user}",
"add": "${domain}",
"port": "80",
"id": "${uuid}",
"aid": "0",
"net": "ws",
"path": "http://tsel.me/worryfree",
"type": "none",
"host": "tsel.me",
"tls": "none"
}
EOF
    )
    cat >/home/vps/public_html/vmess-$user.txt <<-END
_______________________________________________________
Format Vmess WS (CDN)
_______________________________________________________
- name: vmess-$user-WS (CDN)
type: vmess
server: ${domain}
port: 443
uuid: ${uuid}
alterId: 0
cipher: auto
udp: true
tls: true
skip-cert-verify: true
servername: ${domain}
network: ws
ws-opts:
path: /vmess
headers:
Host: ${domain}
_______________________________________________________
Format Vmess WS (CDN) Non TLS
_______________________________________________________
- name: vmess-$user-WS (CDN) Non TLS
type: vmess
server: ${domain}
port: 80
uuid: ${uuid}
alterId: 0
cipher: auto
udp: true
tls: false
skip-cert-verify: false
servername: ${domain}
network: ws
ws-opts:
path: /vmess
headers:
Host: ${domain}
_______________________________________________________
Format Vmess gRPC (SNI)
_______________________________________________________
- name: vmess-$user-gRPC (SNI)
server: ${domain}
port: 443
type: vmess
uuid: ${uuid}
alterId: 0
cipher: auto
network: grpc
tls: true
servername: ${domain}
skip-cert-verify: true
grpc-opts:
grpc-service-name: vmess-grpc
_______________________________________________________
Format Vmess WS (CDN) Non TLS Opok TSEL
_______________________________________________________
- name: vmess-$user-WS (CDN) Non TLS
type: vmess
server: ${domain}
port: 80
uuid: ${uuid}
alterId: 0
cipher: auto
udp: true
tls: false
skip-cert-verify: true
servername: comunity.instagram.com
network: ws
ws-opts:
path: : http://tsel.me/worryfree
headers:
Host: ${domain}
_______________________________________________________
Link Vmess Account
_______________________________________________________
Link TLS : vmess://$(echo $VMESS_WS | base64 -w 0)
_______________________________________________________
Link NTLS : vmess://$(echo $VMESS_NON_TLS | base64 -w 0)
_______________________________________________________
Link gRPC : vmess://$(echo $VMESS_GRPC | base64 -w 0)
_______________________________________________________
Link Opok : vmess://$(echo $VMESS_OPOK | base64 -w 0)
_______________________________________________________
END
    if [ ${Quota} = '9999' ]; then
        TEXT="
◇━━━━━━━━━━━━━━━━━◇
Premium Vmess 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         : <code>/vmess</code>
Path Support : <code>https://bug.com/vmess</code>
ServiceName  : <code>vmess-grpc</code>
◇━━━━━━━━━━━━━━━━━◇
Link TLS     :
<code>${vmesslink1}</code>
◇━━━━━━━━━━━━━━━━━◇
Link NTLS    :
<code>${vmesslink2}</code>
◇━━━━━━━━━━━━━━━━━◇
Link GRPC    :
<code>${vmesslink3}</code>
◇━━━━━━━━━━━━━━━━━◇
Format OpenClash :
http://$domain:89/vmess-$user.txt
◇━━━━━━━━━━━━━━━━━◇
Expired Until    : $exp
◇━━━━━━━━━━━━━━━━━◇
$author
◇━━━━━━━━━━━━━━━━━◇
"
    else
        TEXT="
◇━━━━━━━━━━━━━━━━━◇
Premium Vmess Account
◇━━━━━━━━━━━━━━━━━◇
User         : ${user}
Domain       : <code>${domain}</code>
Login Limit  : ${iplim} IP
Quota Limit  : ${Quota} GB
ISP          : ${ISP}
CITY         : ${CITY}
Expired On   : $exp
Port TLS     : 443
Port NTLS    : 80, 8080
Port GRPC    : 443
UUID         : <code>${uuid}</code>
AlterId      : 0
Security     : auto
Network      : WS or gRPC
Path         : <code>/vmess</code>
Path Support : <code>https://bug.com/vmess</code>
ServiceName  : <code>vmess-grpc</code>
◇━━━━━━━━━━━━━━━━━◇
Link TLS     :
<code>${vmesslink1}</code>
◇━━━━━━━━━━━━━━━━━◇
Link NTLS    :
<code>${vmesslink2}</code>
◇━━━━━━━━━━━━━━━━━◇
Link GRPC    :
<code>${vmesslink3}</code>
◇━━━━━━━━━━━━━━━━━◇
Format OpenClash :
http://$domain:89/vmess-$user.txt
◇━━━━━━━━━━━━━━━━━◇
$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 VMESS 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 VMESS </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 Vmess..</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/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}• Premium Vmess Account • ${NC} $COLOR1 $NC" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}Username ${COLOR1}: ${WH}${user}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}ISP  ${COLOR1}: ${WH}$ISP" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}City ${COLOR1}: ${WH}$CITY" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}Domain  ${COLOR1}: ${WH}${domain}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}Limit IP${COLOR1}: ${WH}${iplim} User" | tee -a /etc/vmess/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/vmess/akun/log-create-${user}.log
    fi
    echo -e "$COLOR1 ${NC} ${WH}Expired On ${COLOR1}: ${WH}$exp" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}Port TLS      ${COLOR1}: ${WH}443" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}Port NTLS    ${COLOR1}: ${WH}80,8080" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}Port gRPC     ${COLOR1}: ${WH}443" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}UUID         ${COLOR1}: ${WH}${uuid}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}alterId       ${COLOR1}: ${WH}0" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}Security      ${COLOR1}: ${WH}auto" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}Network       ${COLOR1}: ${WH}ws" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}Path          ${COLOR1}: ${WH}/vmess" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}Path Support  ${COLOR1}: ${WH}http://bug/vmess" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}ServiceName   ${COLOR1}: ${WH}vmess-grpc" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${COLOR1}Link TLS  ${WH}:    ${vmesslink1}${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${COLOR1}Link NTLS ${WH}:    ${vmesslink2}${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${COLOR1}Link GRPC ${WH}:    ${vmesslink3}${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}Format Openclash ${COLOR1}:" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}http://$domain:89/vmess-$user.txt${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}    $author     " | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo "" | tee -a /etc/vmess/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-vmess() {
    clear
    cd
    echo -e "$COLOR1╭═════════════════════════════════════════════════╮${NC}"
    echo -e "$COLOR1│${NC} ${COLBG1}           ${WH}• Trial Vmess Account •             ${NC} $COLOR1│ $NC"
    echo -e "$COLOR1╰═════════════════════════════════════════════════╯${NC}"
    echo -e ""
    echo -e ""
    until [[ $timer =~ ^[0-9]+$ ]]; do
        read -p "  Expired (Minutes) : " timer
    done
    user=Trial-$(tr </dev/urandom -dc X-Z0-9 | head -c4)
    iplim=1
    Quota=10
    uuid=$(cat /proc/sys/kernel/random/uuid)
    masaaktif=0
    if [ ! -e /etc/vmess ]; then
        mkdir -p /etc/vmess
    fi
    c=$(echo "${Quota}" | sed 's/[^0-9]*//g')
    d=$((${c} * 1024 * 1024 * 1024))
    if [[ ${c} != "0" ]]; then
        echo "${d}" >/etc/vmess/${user}
    fi
    echo "${iplim}" >/etc/vmess/${user}IP
    exp=$(date -d "$masaaktif days" +"%Y-%m-%d")
    sed -i '/#vmess$/a\#vm '"$user $exp"'\
},{"id": "'""$uuid""'","alterId": '"0"',"email": "'""$user""'"' /etc/xray/config.json
    sed -i '/#vmessgrpc$/a\#vmg '"$user $exp $uuid"'\
},{"id": "'""$uuid""'","alterId": '"0"',"email": "'""$user""'"' /etc/xray/config.json
    cat >/etc/cron.d/trialvmess${user} <<EOF
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
*/$timer * * * * root /usr/bin/trial vmess $user $uuid $exp
EOF
    asu=$(cat <<EOF
{
"v": "2",
"ps": "${user}",
"add": "${domain}",
"port": "443",
"id": "${uuid}",
"aid": "0",
"net": "ws",
"path": "/vmess",
"type": "none",
"host": "${domain}",
"tls": "tls"
}
EOF
    )
    ask=$(cat <<EOF
{
"v": "2",
"ps": "${user}",
"add": "${domain}",
"port": "80",
"id": "${uuid}",
"aid": "0",
"net": "ws",
"path": "/vmess",
"type": "none",
"host": "${domain}",
"tls": "none"
}
EOF
    )
    grpc=$(cat <<EOF
{
"v": "2",
"ps": "${user}",
"add": "${domain}",
"port": "443",
"id": "${uuid}",
"aid": "0",
"net": "grpc",
"path": "vmess-grpc",
"type": "none",
"host": "${domain}",
"tls": "tls"
}
EOF
    )
    vmess_base641=$(base64 -w 0 <<<$vmess_json1)
    vmess_base642=$(base64 -w 0 <<<$vmess_json2)
    vmess_base643=$(base64 -w 0 <<<$vmess_json3)
    vmesslink1="vmess://$(echo $asu | base64 -w 0)"
    vmesslink2="vmess://$(echo $ask | base64 -w 0)"
    vmesslink3="vmess://$(echo $grpc | base64 -w 0)"
    VMESS_WS=$(cat <<EOF
{
"v": "2",
"ps": "${user}",
"add": "${domain}",
"port": "443",
"id": "${uuid}",
"aid": "0",
"net": "ws",
"path": "/vmess",
"type": "none",
"host": "${domain}",
"tls": "tls"
}
EOF
    )
    VMESS_NON_TLS=$(cat <<EOF
{
"v": "2",
"ps": "${user}",
"add": "${domain}",
"port": "80",
"id": "${uuid}",
"aid": "0",
"net": "ws",
"path": "/vmess",
"type": "none",
"host": "${domain}",
"tls": "none"
}
EOF
    )
    VMESS_GRPC=$(cat <<EOF
{
"v": "2",
"ps": "${user}",
"add": "${domain}",
"port": "443",
"id": "${uuid}",
"aid": "0",
"net": "grpc",
"path": "/vmess-grpc",
"type": "none",
"host": "${domain}",
"tls": "tls"
}
EOF
    )
    VMESS_OPOK=$(cat <<EOF
{
"v": "2",
"ps": "${user}",
"add": "${domain}",
"port": "80",
"id": "${uuid}",
"aid": "0",
"net": "ws",
"path": "http://tsel.me/worryfree",
"type": "none",
"host": "tsel.me",
"tls": "none"
}
EOF
    )
    cat >/home/vps/public_html/vmess-$user.txt <<-END
_______________________________________________________
Format Vmess WS (CDN)
_______________________________________________________
- name: vmess-$user-WS (CDN)
type: vmess
server: ${domain}
port: 443
uuid: ${uuid}
alterId: 0
cipher: auto
udp: true
tls: true
skip-cert-verify: true
servername: ${domain}
network: ws
ws-opts:
path: /vmess
headers:
Host: ${domain}
_______________________________________________________
Format Vmess WS (CDN) Non TLS
_______________________________________________________
- name: vmess-$user-WS (CDN) Non TLS
type: vmess
server: ${domain}
port: 80
uuid: ${uuid}
alterId: 0
cipher: auto
udp: true
tls: false
skip-cert-verify: false
servername: ${domain}
network: ws
ws-opts:
path: /vmess
headers:
Host: ${domain}
_______________________________________________________
Format Vmess gRPC (SNI)
_______________________________________________________
- name: vmess-$user-gRPC (SNI)
server: ${domain}
port: 443
type: vmess
uuid: ${uuid}
alterId: 0
cipher: auto
network: grpc
tls: true
servername: ${domain}
skip-cert-verify: true
grpc-opts:
grpc-service-name: vmess-grpc
_______________________________________________________
Format Vmess WS (CDN) Non TLS Opok TSEL
_______________________________________________________
- name: vmess-$user-WS (CDN) Non TLS
type: vmess
server: ${domain}
port: 80
uuid: ${uuid}
alterId: 0
cipher: auto
udp: true
tls: false
skip-cert-verify: true
servername: comunity.instagram.com
network: ws
ws-opts:
path: http://tsel.me/worryfree
headers:
Host: ${domain}
_______________________________________________________
Link Vmess Account
_______________________________________________________
Link TLS : vmess://$(echo $VMESS_WS | base64 -w 0)
_______________________________________________________
Link NTLS : vmess://$(echo $VMESS_NON_TLS | base64 -w 0)
_______________________________________________________
Link gRPC : vmess://$(echo $VMESS_GRPC | base64 -w 0)
_______________________________________________________
Link Opok : vmess://$(echo $VMESS_OPOK | base64 -w 0)
_______________________________________________________
END
    TEXT="
◇━━━━━━━━━━━━━━━━━◇
Trial Premium Vmess 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         : <code>/vmess</code>
Path Support : <code>https://bug.com/vmess</code>
ServiceName  : <code>vmess-grpc</code>
◇━━━━━━━━━━━━━━━━━◇
Link TLS     :
<code>${vmesslink1}</code>
◇━━━━━━━━━━━━━━━━━◇
Link NTLS    :
<code>${vmesslink2}</code>
◇━━━━━━━━━━━━━━━━━◇
Link GRPC    :
<code>${vmesslink3}</code>
◇━━━━━━━━━━━━━━━━━◇
Format OpenClash :
http://$domain:89/vmess-$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/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}• Trial Premium Vmess Account • ${NC} $COLOR1 $NC" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Username   ${COLOR1}: ${WH}${user}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}ISP        ${COLOR1}: ${WH}$ISP" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}City       ${COLOR1}: ${WH}$CITY" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Domain     ${COLOR1}: ${WH}${domain}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Login Limit ${COLOR1}: ${WH}${iplim} IP" | tee -a /etc/log-create-.log
    echo -e "$COLOR1 ${NC} ${WH}Expired On ${COLOR1}: ${WH}$timer Minutes" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Port TLS   ${COLOR1}: ${WH}443" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Port NTLS  ${COLOR1}: ${WH}80,8080" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Port gRPC  ${COLOR1}: ${WH}443" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}UUID       ${COLOR1}: ${WH}${uuid}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}alterId    ${COLOR1}: ${WH}0" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Security   ${COLOR1}: ${WH}auto" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Network    ${COLOR1}: ${WH}ws" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Path      ${COLOR1}: ${WH}/vmess" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Path Support  ${COLOR1}: ${WH}http://bug/vmess" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}ServiceName   ${COLOR1}: ${WH}vmess-grpc" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${COLOR1}Link Websocket TLS      ${WH}:${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}     ${vmesslink1}${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${COLOR1}Link Websocket NTLS ${WH}: ${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}     ${vmesslink2}${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${COLOR1}Link Websocket gRPC     ${WH}: ${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1${NC}${WH}     ${vmesslink3}${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}Format Openclash ${COLOR1}:" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}http://$domain:89/vmess-$user.txt${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ${NC} ${WH}    $author     " | tee -a /etc/vmess/akun/log-create-${user}.log
    echo -e "$COLOR1 ◇━━━━━━━━━━━━━━━━━◇ ${NC}" | tee -a /etc/vmess/akun/log-create-${user}.log
    echo "" | tee -a /etc/vmess/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 renew-vmess() {
    clear
    NUMBER_OF_CLIENTS=$(grep -c -E "^#vmg " "/etc/xray/config.json")
    if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
        clear
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Renew Vmess 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-vmess
    fi
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Renew Vmess 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 "^#vmg " "/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-vmess
            fi
        fi
    done
    read -p "Expired (days): " masaaktif
    user=$(grep -E "^#vmg " "/etc/xray/config.json" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
    exp=$(grep -E "^#vmg " "/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/#vm $user $exp/#vm $user $exp4/g" /etc/xray/config.json
    sed -i "s/#vmg $user $exp/#vmg $user $exp4/g" /etc/xray/config.json
    clear
    TEXT="
<code>◇━━━━━━━━━━━━━━◇</code>
<b>   XRAY VMESS 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 VMESS 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 VMESS </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
    systemctl restart xray >/dev/null 2>&1
    clear
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo " VMESS 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-vmess
}
function limit-vmess() {
    clear
    NUMBER_OF_CLIENTS=$(grep -c -E "^#vmg " "/etc/xray/config.json")
    if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
        clear
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Limit Vmess 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-vmess
    fi
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Limit Vmess 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 "^#vmg " "/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-vmess
            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/vmess ]; then
        mkdir -p /etc/vmess
    fi
    if [ ${iplim} = '0' ]; then
        iplim="9999"
    fi
    if [ ${Quota} = '0' ]; then
        Quota="9999"
    fi
    user=$(grep -E "^#vmg " "/etc/xray/config.json" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
    echo "${iplim}" >/etc/vmess/${user}IP
    c=$(echo "${Quota}" | sed 's/[^0-9]*//g')
    d=$((${c} * 1024 * 1024 * 1024))
    if [[ ${c} != "0" ]]; then
        echo "${d}" >/etc/vmess/${user}
    fi
    TEXT="
<code>◇━━━━━━━━━━━━━━◇</code>
<b>  XRAY VMESS 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 this 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 " VMESS 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-vmess
}
function del-vmess() {
    clear
    NUMBER_OF_CLIENTS=$(grep -c -E "^#vmg " "/etc/xray/config.json")
    if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Delete Vmess 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-vmess
    fi
    clear
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Delete Vmess 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-vmess
    elif [[ $delete_mode == "1" ]]; then
        # SINGLE USER DELETE
        clear
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Delete Single Vmess 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 "^#vmg " "/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-vmess
                fi
            fi
        done
        user=$(grep -E "^#vmg " "/etc/xray/config.json" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
        exp=$(grep -E "^#vmg " "/etc/xray/config.json" | cut -d ' ' -f 3 | sed -n "${CLIENT_NUMBER}"p)
        uuid=$(grep -E "^#vmg " "/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/vmess/akundelete ]; then
                echo "" >/etc/vmess/akundelete
            fi
            echo "### $user $exp $uuid" >>/etc/vmess/akundelete
            sed -i "/^#vmg $user $exp/,/^},{/d" /etc/xray/config.json
            sed -i "/^#vm $user $exp/,/^},{/d" /etc/xray/config.json
            rm /home/vps/public_html/vmess-$user.txt >/dev/null 2>&1
            rm /etc/vmess/${user}IP >/dev/null 2>&1
            rm /etc/vmess/${user}login >/dev/null 2>&1
            systemctl restart xray >/dev/null 2>&1

            TEXT="
<code>◇━━━━━━━━━━━━━━◇</code>
<b>  XRAY VMESS 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 Vmess 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 "^#vmg " "/etc/xray/config.json" | cut -d ' ' -f 2-3 | nl -s ') '
        echo ""
        read -rp "Masukkan pilihan: " selection

        if [[ $selection == "0" ]]; then
            m-vmess
        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 =~ ^#vmg\ (.*)\ (.*)\ (.*)$ ]]; then
                        user="${BASH_REMATCH[1]}"
                        exp="${BASH_REMATCH[2]}"
                        uuid="${BASH_REMATCH[3]}"
                        # Delete user
                        if [ ! -e /etc/vmess/akundelete ]; then
                            echo "" >/etc/vmess/akundelete
                        fi
                        echo "### $user $exp $uuid" >>/etc/vmess/akundelete
                        sed -i "/^#vmg $user $exp/,/^},{/d" /etc/xray/config.json
                        sed -i "/^#vm $user $exp/,/^},{/d" /etc/xray/config.json
                        rm /home/vps/public_html/vmess-$user.txt >/dev/null 2>&1
                        rm /etc/vmess/${user}IP >/dev/null 2>&1
                        rm /etc/vmess/${user}login >/dev/null 2>&1
                        deleted_count=$((deleted_count + 1))
                        deleted_users="$deleted_users$user, "
                    fi
                done < <(grep -E "^#vmg " "/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 VMESS 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 "^#vmg " "/etc/xray/config.json" | cut -d ' ' -f 2 | sed -n "${num}p")
                    exp=$(grep -E "^#vmg " "/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 "^#vmg " "/etc/xray/config.json" | cut -d ' ' -f 2 | sed -n "${num}p")
                        exp=$(grep -E "^#vmg " "/etc/xray/config.json" | cut -d ' ' -f 3 | sed -n "${num}p")
                        uuid=$(grep -E "^#vmg " "/etc/xray/config.json" | cut -d ' ' -f 4 | sed -n "${num}p")

                        if [ ! -e /etc/vmess/akundelete ]; then
                            echo "" >/etc/vmess/akundelete
                        fi
                        echo "### $user $exp $uuid" >>/etc/vmess/akundelete
                        sed -i "/^#vmg $user $exp/,/^},{/d" /etc/xray/config.json
                        sed -i "/^#vm $user $exp/,/^},{/d" /etc/xray/config.json
                        rm /home/vps/public_html/vmess-$user.txt >/dev/null 2>&1
                        rm /etc/vmess/${user}IP >/dev/null 2>&1
                        rm /etc/vmess/${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 VMESS 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 Vmess Users ⇲  ${NC} $COLOR1 $NC"
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo ""

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

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

        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e " Ditemukan $trial_count user trial vmess:"
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo ""
        echo "List Trial Vmess Users:"
        grep -E "^#vmg 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 vmess!"
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        read -rp "Yakin ingin delete semua user trial vmess? 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 =~ ^#vmg\ (trial-.*)\ (.*)\ (.*)$ ]]; then
                    user="${BASH_REMATCH[1]}"
                    exp="${BASH_REMATCH[2]}"
                    uuid="${BASH_REMATCH[3]}"

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

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

                    # Cancel any pending AT jobs for this trial user
                    at -l | grep delete_trial_${user} | awk '{print $1}' | xargs -r atrm >/dev/null 2>&1
                    rm /tmp/delete_trial_${user}.sh >/dev/null 2>&1

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

                    echo "User trial vmess $user berhasil dihapus."
                fi
            done < <(grep -E "^#vmg 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 vmess: $deleted_users"

            # Send telegram notification
            TEXT="
<code>◇━━━━━━━━━━━━━━◇</code>
<b>  DELETE ALL TRIAL VMESS USERS</b>
<code>◇━━━━━━━━━━━━━━◇</code>
<b>DOMAIN   :</b> <code>${domain} </code>
<b>ISP      :</b> <code>$ISP $CITY </code>
<b>DELETED  :</b> <code>$deleted_count trial vmess users</code>
<b>USERS    :</b> <code>$deleted_users</code>
<code>◇━━━━━━━━━━━━━━◇</code>
<i>All Trial Vmess 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 vmess users dibatalkan."
        fi

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

    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo ""
    read -n 1 -s -r -p "Press any key to back on menu"
    m-vmess
}
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-vmess() {
    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}• VMESS USER ONLINE •              ${NC} $COLOR1│ $NC"
    echo -e "$COLOR1╰═════════════════════════════════════════════════╯${NC}"
    echo -e "$COLOR1╭═══════════════════════════════════════════════════╮${NC}"
    vm=($(cat /etc/xray/config.json | grep "^#vmg" | 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/vmess/${vmuser})
                gb=$(convert ${byt})
                lim=$(cat /etc/vmess/${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-vmess
}
function list-vmess() {
    clear
    NUMBER_OF_CLIENTS=$(grep -c -E "^#vmg " "/etc/xray/config.json")
    if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
        clear
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Config Vmess 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-vmess
    fi
    clear
    echo ""
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Config Vmess 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━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo "     No  User   Expired"
    grep -E "^#vmg " "/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-vmess
            fi
        fi
    done
    clear
    user=$(grep -E "^#vmg " "/etc/xray/config.json" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
    cat /etc/vmess/akun/log-create-${user}.log
    cat /etc/vmess/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-vmess
}
clear
function login-vmess() {
    clear
    echo -e "$COLOR1╭══════════════════════════════════════════╮${NC}"
    echo -e "$COLOR1│ \033[1;37mPlease select a your Choice              $COLOR1│${NC}"
    echo -e "$COLOR1╰══════════════════════════════════════════╯${NC}"
    echo -e ""
    echo -e "$COLOR1╭══════════════════════════════════════════╮${NC}"
    echo -e "$COLOR1│  [ 1 ]  \033[1;37mAUTO LOCKED USER ALL XRAY      ${NC}"
    echo -e "$COLOR1│  [ 2 ]  \033[1;37mAUTO DELETE USER ALL XRAY    ${NC}"
    echo -e "$COLOR1│  [ 0 ]  \033[1;37mBACK TO MENU    ${NC}"
    echo -e "$COLOR1╰══════════════════════════════════════════╯${NC}"
    until [[ $lock =~ ^[0-2]+$ ]]; do
        read -p "    select numbers 1/2 : " lock
    done
    if [[ $lock == "0" ]]; then
        menu
    elif [[ $lock == "1" ]]; then
        clear
        echo "lock" >/etc/typexray
        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 Auto Lock  ${NC}"
        echo -e "$COLOR1│$NC Jika User Melanggar auto lock Account. ${NC}"
        echo -e "$COLOR1╰═══════════════════════════════════════════════╯${NC}"
        sleep 1
    elif [[ $lock == "2" ]]; then
        clear
        echo "delete" >/etc/typexray
        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 Auto Delete Account ${NC}"
        echo -e "$COLOR1│$NC Jika User Melanggar auto Delete Account. ${NC}"
        echo -e "$COLOR1╰═══════════════════════════════════════════════╯${NC}"
        sleep 1
    fi
    type=$(cat /etc/typexray)
    if [ $type = "lock" ]; then
        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 WAKTU UNTUK LOCKED  ${NC}"
        echo -e "$COLOR1│$NC BISA TULIS 15 MENIT DLL. ${NC}"
        echo -e "$COLOR1╰═══════════════════════════════════════════════╯${NC}"
        read -rp "   Jumlah Waktu Lock: " -e notif2
        echo "${notif2}" >/etc/waktulock
        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 AUTO 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
        echo "$notif" >/etc/vless/notif
        echo "$notif" >/etc/vmess/notif
        echo "$notif" >/etc/trojan/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 SUCCES GANTI TIME NOTIF LOCK JADI $notif2 MENIT $NC "
        echo -e "$COLOR1╰═══════════════════════════════════════════════╯${NC}"
    else
        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 WAKTU UNTUK USER YANG MULTI LOGIN   ${NC}"
        echo -e "${COLOR1}│ $NC TIAP MENIT JADI NOTIF TIAP BEBERAPA MENIT. ${NC}"
        echo -e "$COLOR1╰═══════════════════════════════════════════════╯${NC}"
        read -rp "   Jika Mau 3menit baru keNotif tulis 3, dst: " -e notif2
        echo "# Autokill" >/etc/cron.d/xraylimit
        echo "SHELL=/bin/sh" >>/etc/cron.d/xraylimit
        echo "PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" >>/etc/cron.d/xraylimit
        echo "*/$notif2 * * * *  root /usr/bin/xraylimit" >>/etc/cron.d/xraylimit
        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
        echo "$notif" >/etc/vless/notif
        echo "$notif" >/etc/vmess/notif
        echo "$notif" >/etc/trojan/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 SUCCES GANTI TIME NOTIF LOCK JADI $notif2 MENIT $NC "
        echo -e "$COLOR1╰═══════════════════════════════════════════════╯${NC}"
    fi
    read -n 1 -s -r -p "Press any key to back on menu"
    m-vmess
}
function lock-vmess() {
    clear
    cd
    if [ ! -e /etc/vmess/listlock ]; then
        echo "" >/etc/vmess/listlock
    fi
    NUMBER_OF_CLIENTS=$(grep -c -E "^### " "/etc/vmess/listlock")
    if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Unlock Vmess 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-vmess
    fi
    clear
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Unlock Vmess 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/vmess/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-vmess
            fi
            if [[ ${CLIENT_NUMBER} == '999' ]]; then
                rm /etc/vmess/listlock
                m-vmess
            fi
        fi
    done
    user=$(grep -E "^### " "/etc/vmess/listlock" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
    exp=$(grep -E "^### " "/etc/vmess/listlock" | cut -d ' ' -f 3 | sed -n "${CLIENT_NUMBER}"p)
    uuid=$(grep -E "^### " "/etc/vmess/listlock" | cut -d ' ' -f 4 | sed -n "${CLIENT_NUMBER}"p)
    sed -i '/#vmess$/a\#vm '"$user $exp"'\
},{"id": "'""$uuid""'","alterId": '"0"',"email": "'""$user""'"' /etc/xray/config.json
    sed -i '/#vmessgrpc$/a\#vmg '"$user $exp $uuid"'\
},{"id": "'""$uuid""'","alterId": '"0"',"email": "'""$user""'"' /etc/xray/config.json
    sed -i "/^### $user $exp $uuid/d" /etc/vmess/listlock
    systemctl restart xray
    TEXT="
<code>◇━━━━━━━━━━━━━━◇</code>
<b>  XRAY VMESS 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
    clear
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo " Vmess 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-vmess
}
function res-user() {
    clear
    cd
    if [ ! -e /etc/vmess/akundelete ]; then
        echo "" >/etc/vmess/akundelete
    fi
    clear
    NUMBER_OF_CLIENTS=$(grep -c -E "^### " "/etc/vmess/akundelete")
    if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Restore Vmess 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-vmess
    fi
    clear
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Restore Vmess 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/vmess/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-vmess
            fi
            if [[ ${CLIENT_NUMBER} == '999' ]]; then
                rm /etc/vmess/akundelete
                m-vmess
            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/vmess/akundelete" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
    exp=$(date -d "$masaaktif days" +"%Y-%m-%d")
    uuid=$(grep -E "^### " "/etc/vmess/akundelete" | cut -d ' ' -f 4 | sed -n "${CLIENT_NUMBER}"p)
    sed -i '/#vmess$/a\#vm '"$user $exp"'\
},{"id": "'""$uuid""'","alterId": '"0"',"email": "'""$user""'"' /etc/xray/config.json
    sed -i '/#vmessgrpc$/a\#vmg '"$user $exp $uuid"'\
},{"id": "'""$uuid""'","alterId": '"0"',"email": "'""$user""'"' /etc/xray/config.json
    echo "${iplim}" >/etc/vmess/${user}IP
    c=$(echo "${Quota}" | sed 's/[^0-9]*//g')
    d=$((${c} * 1024 * 1024 * 1024))
    if [[ ${c} != "0" ]]; then
        echo "${d}" >/etc/vmess/${user}
    fi
    sed -i "/### ${user} ${exp} ${uuid}/d" /etc/vmess/akundelete
    systemctl restart xray
    TEXT="
<code>◇━━━━━━━━━━━━━━◇</code>
<b>  XRAY VMESS 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
    clear
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo " Vmess Account Restore Successfully"
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo " DOMAIN : $domain"
    echo " ISP  : $ISP $CITY"
    echo " USERNAME : $user"
    echo " IP LIMIT : $iplim IP"
    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-vmess
}
function quota-user() {
    clear
    cd
    if [ ! -e /etc/vmess/userQuota ]; then
        echo "" >/etc/vmess/userQuota
    fi
    NUMBER_OF_CLIENTS=$(grep -c -E "^### " "/etc/vmess/userQuota")
    if [[ ${NUMBER_OF_CLIENTS} == '0' ]]; then
        echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Unlock Vmess 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-vmess
    fi
    clear
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo -e "$COLOR1 ${NC}${COLBG1}    ${WH}⇱ Unlock Vmess 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/vmess/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-vmess
            fi
            if [[ ${CLIENT_NUMBER} == '999' ]]; then
                rm /etc/vmess/userQuota
                m-vmess
            fi
        fi
    done
    user=$(grep -E "^### " "/etc/vmess/userQuota" | cut -d ' ' -f 2 | sed -n "${CLIENT_NUMBER}"p)
    exp=$(grep -E "^### " "/etc/vmess/userQuota" | cut -d ' ' -f 3 | sed -n "${CLIENT_NUMBER}"p)
    uuid=$(grep -E "^### " "/etc/vmess/userQuota" | cut -d ' ' -f 4 | sed -n "${CLIENT_NUMBER}"p)
    sed -i '/#vmess$/a\#vm '"$user $exp"'\
},{"id": "'""$uuid""'","alterId": '"0"',"email": "'""$user""'"' /etc/xray/config.json
    sed -i '/#vmessgrpc$/a\#vmg '"$user $exp $uuid"'\
},{"id": "'""$uuid""'","alterId": '"0"',"email": "'""$user""'"' /etc/xray/config.json
    sed -i "/^### $user $exp $uuid/d" /etc/vmess/userQuota
    systemctl restart xray
    TEXT="
<code>◇━━━━━━━━━━━━━━◇</code>
<b>  XRAY VMESS 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
    clear
    echo -e "$COLOR1━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    echo " Vmess 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-vmess
}
clear
echo -e " $COLOR1╭════════════════════════════════════════════════════╮${NC}"
echo -e " $COLOR1│${NC} ${COLBG1}            ${WH}• VMESS 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
01 | 1)
    clear
    add-vmess
    ;;
02 | 2)
    clear
    trial-vmess
    ;;
03 | 3)
    clear
    renew-vmess
    ;;
04 | 4)
    clear
    del-vmess
    ;;
05 | 5)
    clear
    cek-vmess
    ;;
06 | 6)
    clear
    list-vmess
    ;;
07 | 7)
    clear
    limit-vmess
    ;;
08 | 8)
    clear
    login-vmess
    ;;
09 | 9)
    clear
    lock-vmess
    ;;
10 | 10)
    clear
    quota-user
    ;;
11 | 11)
    clear
    res-user
    ;;
00 | 0)
    clear
    menu
    ;;
*)
    clear
    m-vmess
    ;;
esac
