#!/bin/bash
# -*- ENCODING: UTF-8 -*-

meu_ip_fun () {
    MIP=$(ip addr | grep 'inet' | grep -v inet6 | grep -vE '127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -o -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1)
    MIP2=$(wget -qO- ipv4.icanhazip.com)
    [[ "$MIP" != "$MIP2" ]] && IP="$MIP2" || IP="$MIP"
}

meu_ip_func () {
    MIP=$(ip addr | grep 'inet' | grep -v inet6 | grep -vE '127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -o -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1)
    MIP2=$(wget -qO- ipv4.icanhazip.com)
    [[ "$MIP" != "$MIP2" ]] && IP="$MIP2" || IP="$MIP"
}

rm -rf /etc/localtime &>/dev/null
ln -s /usr/share/zoneinfo/America/Chihuahua /etc/localtime &>/dev/null
rm -rf /usr/local/lib/systemubu1 &>/dev/null

#!/bin/bash
# -*- ENCODING: UTF-8 -*-

# --------------------------------------
# Sección de Constantes
# --------------------------------------
# Línea divisoria utilizada en la salida del bot
LINE="━━━━━━━━━━━━━━━━━━"

# Rutas principales
SCPT_DIR="/etc/scripts/latam"
SCPT_DIRC="/etc/scripts/vpsmx"
DIR="/etc/http-shell"
CIDdir="/etc/adm-db"
USRdatabase2="/etc/adm-db/Creditos"

# Archivos y directorios específicos
LIST="lista-arq"
CIDRESS="${CIDdir}/RESSELLERS"
SRC="${CIDdir}/sources"
CID="${CIDdir}/User-ID"
CIDB="${CIDdir}/regcup"
CIDC="${CIDdir}/User-Hist"
keytxt="${CIDdir}/keys"

# --------------------------------------
# Configuración de Listas de Archivos
# --------------------------------------
# Lista de archivos para BASICINST (si no existe /etc/newadm-instal)
BASICINST_DEFAULT="menu.sh LATAMbot.sh PDirect.py PGet.py POpen.py PPriv.py PPub.py message.txt"
# Lista de archivos para BASICINSTC (si no existe /etc/newadm-install)
BASICINSTC_DEFAULT="ID.txt slowdns.sh ADMbot.sh C-SSR.sh Crear-Demo.sh PDirect.py PGet.py POpen.py PPriv.py PPub.py apacheon.sh blockBT.sh budp.sh dns-netflix.sh dropbear.sh fai2ban.sh message.txt openvpn.sh paysnd.sh ports.sh sockspy.sh speed.py squid.sh squidpass.sh ssl.sh tcp.sh ultrahost v2ray.sh python.py"
#BASICINSTC_DEFAULT="ID menu message.txt dropbear.sh proxy.sh wireguard.sh openvpn.sh ssl.sh python.py shadowsocks.sh Shadowsocks-libev.sh Shadowsocks-R.sh v2ray.sh slowdns.sh budp.sh name adminkey sockspy.sh PDirect.py PPub.py PPriv.py POpen.py PGet.py"
# Cargar listas desde archivos si existen, o usar valores por defecto
[[ -e /etc/newadm-instal ]] && BASICINST="$(cat /etc/newadm-instal)" || BASICINST="${BASICINST_DEFAULT}"
[[ -e /etc/newadm-install ]] && BASICINSTC="$(cat /etc/newadm-install)" || BASICINSTC="${BASICINSTC_DEFAULT}"

# --------------------------------------
# Creación de Directorios
# --------------------------------------
# Crear directorios necesarios si no existen
[[ ! -e "${SCPT_DIR}" ]] && mkdir "${SCPT_DIR}"
[[ ! -e "${SCPT_DIRC}" ]] && mkdir "${SCPT_DIRC}"
[[ ! -d "${CIDdir}" ]] && mkdir "${CIDdir}"
[[ ! -e "${CIDRESS}" ]] && mkdir "${CIDRESS}"
[[ ! -d "${SRC}" ]] && mkdir "${SRC}"
[[ ! -d "${keytxt}" ]] && mkdir "${keytxt}"
[[ ! -d "${USRdatabase2}" ]] && mkdir "${USRdatabase2}"
mkdir /etc/bot/creditos

# --------------------------------------
# Creación de Archivos
# --------------------------------------
# Crear archivos necesarios si no existen
[[ ! -e "${CID}" ]] && touch "${CID}"
[[ ! -e "${CIDB}" ]] && touch "${CIDB}"
[[ ! -e "${CIDC}" ]] && touch "${CIDC}"
touch lista
[[ ! -e RESET ]] && touch RESET

# --------------------------------------
# Configuración de Dependencias
# --------------------------------------
# Instalar jq si no está presente
[[ $(dpkg --get-selections | grep -w "jq" | head -1) ]] || apt-get install jq 	 	 	apt-get install jq -y &>/dev/null

# Descargar ShellBot.sh si no existe
[[ ! -e "/bin/ShellBot.sh" ]] && wget -O /bin/ShellBot.sh https://www.dropbox.com/s/gfwlkfq4f2kplze/ShellBot.sh &>/dev/null

# --------------------------------------
# Limpieza de Archivos Temporales
# --------------------------------------
# Eliminar archivo de texto-bot si existe
[[ -e /etc/texto-bot ]] && rm /etc/texto-bot

fsub='subdomain.log'
txt[0]='Ingresa tu IP:'
txt[1]='Ingresa el subdominio:'
txt[2]='Ingresa tu reseller:'
# Importando API 
source ShellBot.sh

# Token del bot
#bot_token="$(cat ${CIDdir}/token)"
bot_token=$(cat /etc/adm-db/data|awk -F '|' '{print $1}')
adm=$(cat $CIDdir/data|awk -F '|' '{print $2}')

# Inicializando el bot
ShellBot.init --token "$bot_token" --monitor --flush --return map
ShellBot.username

ShellBot.setMyCommands --commands '[{"command":"menu","description":"muestra el menu principal"},{"command":"id","description":"muestra tu id de telegram"}]'

reply () {
	[[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}

 	 ShellBot.sendMessage	--chat_id  $var \
				--text "$(echo -e "${bot_retorno:=$comando}")" \
					--parse_mode html --reply_markup "$(ShellBot.ForceReply)"
}
replydos () {
	[[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}

 	 ShellBot.sendMessage	--chat_id  $var \
				--text "$(echo -e "${bot_retorno:=$comando}")" \
					--parse_mode html --reply_markup "$(ShellBot.ForceReply)"
}


datauser() {
    # Constantes
    #local LINE="━━━━━━━━━━━━━━━━━━"
    local check=([0]="🔴 ●--  <b>SIN ACCESO VIP</b>" [1]="🟢|-- <b>CON ACCESO VIP</b>" [2]="<b>BIENVENIDO ADMIN</b>")

    # Determinar datos del usuario
    name=${message_from_first_name[$id]:-${callback_query_from_first_name}}
    username=${message_from_username[$id]:-${callback_query_from_username[$id]}}
    var=${callback_query_message_chat_id[$id]:-${message_chat_id[$id]}}

    # Verificar permisos
    if [[ "$permited" != "$chatuser" ]]; then
        usr=$(grep -q "$chatuser" ${CIDdir}/User-ID && echo 1 || echo 0)
    else
        usr=2
    fi

    # Actualizar nombre desde configuración, si existe
    [[ -e ${CIDRESS}/${chatuser}.conf ]] && name=$(cat ${CIDRESS}/${chatuser}.conf)

    # Construir respuesta
    bot_retorno="$LINE\n━━━━◢ <b>MENU PRINCIPAL</b> ◣━━━━\n\n"
    bot_retorno+="👤 |-- [ $name ]\n👤 |-- [ <b>@$username</b> ]\n🆔 |-- [ <code>$var</code> ]\n\n"
    bot_retorno+="<b>${check[$usr]}</b>\n$LINE\n"
}


# verificacion primarias KEYS CON ACCESO

gerar_keys () {
    MSG_id=$((${message_message_id} + 1))
    meu_ip_fun
    #Verificador de keys
    unset checkPID_GEN
    checkPID_GEN=$(ps x|grep -v grep|grep "8888")
    [[ ! $checkPID_GEN ]] && checkPID_GEN='️⚠️ ESTADO ⚠️ NO USAR! Esta Key es Invalida🚨' || checkPID_GEN=''
    [[ ! -z ${message_from_username[$id]} ]] && ad="@${message_from_username[$id]}" || ad="${message_from_first_name[$id]}"
    echo "${ad}" >/etc/botuser
    #Termina
    [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
    [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
    unset newresell
    newresell="${USRdatabase2}/Mensaje_$chatuser.txt"
    if [[ ! -e ${newresell} ]]; then
        echo "${firsnme} ${lastnme}" > ${SCPT_DIR}/message.txt
    else
        echo "$(cat ${newresell})" > ${SCPT_DIR}/message.txt
    fi

    [[ ! $newresell ]] && credill="By $(cat ${USRdatabase2}/Mensaje_$chatuser.txt)" || credill="By $(cat ${SCPT_DIR}/message.txt)"

    [[ ! ${keytxt}/key_$chatuser.txt ]] && kg="0" || kg=$(cat ${keytxt}/key_$chatuser.txt | wc -l)

    unset usrLOP nombrevalue nBot nBotSS

    unset nombrevalue
    [[ -z ${nombrevalue} ]] && nombrevalue="${message_from_id}"
    [[ -z ${nombrevalue} ]] && nombrevalue="${callback_query_from_id}"
    numkey_gen=$(grep -o -i $nombrevalue /etc/adm-db/num-key.cont | wc -l)
    limcont=$(cat /etc/adm-db/limit)
    [[ "$limcont" -ge "998" ]] && limted="♾️" || limted=$(cat /etc/adm-db/limit)
    [[ "$(( $limcont - $numkey_gen ))" -ge "900" ]] && credres="♾️" || credres=$(( $limcont - $numkey_gen))
    [[ -z $nBot ]] && nBot=$(ShellBot.username)
    valuekey="$(date | md5sum | head -c10)"
    valuekey+="$(echo $(($RANDOM*10))|head -c 5)"
    fun_list "$valuekey"
    keyfinal=$(ofus "$IP:8888/$valuekey/$LIST")
    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
                                  --text "️GENERANDO KEY CASITA"
    local bot_retorno="┅┅┅⋙💥❯❯ ❯❯❲ BOT GEN ❳❮❮ ❮❮💥⋘┅┅┅ \n"
    bot_retorno+="\n"
    [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
    [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
    [[ -z ${message_chat_tittle} ]] && grupCHAT="" || grupCHAT="ChatID : ${chatuser} "
    [[ -z ${usrLOP} ]] && bot_retorno+="🆔 ●⸺ [ <tg-spoiler>${nombrevalue}</tg-spoiler> $grupCHAT ] \n"
    bot_retorno+="🔑 KEY GENERADA DARNIX🔑 \n"
    bot_retorno+="\n"
    bot_retorno+="👤 SLOGAN: : $credill\n"
    bot_retorno+="$(cat < /etc/adm-db/resel)\n"
    bot_retorno+="\n"
    bot_retorno+="💾 Instalador:\n"
    bot_retorno+="\n"
    bot_retorno+="<pre>apt update -y; apt list --upgradable; apt upgrade -y; wget --no-check-certificate https://gitea.com/darnix1/darnix/raw/branch/main/LACASITA.sh; chmod 777 LACASITA.sh; ./LACASITA.sh</pre>\n\n"
    bot_retorno+="\n"
    bot_retorno+="🔑 Key: (Valida por solo 30 min) \n"
    bot_retorno+="\n"
    bot_retorno+="<code>${keyfinal}</code>\n"
    bot_retorno+="$checkPID_GEN\n"
    bot_retorno+="$LINE\n"
    bot_retorno+="KEY GENERADAS EN 24hrs: [ $credres/$limted ]\n"
    bot_retorno+="$LINE\n"
    echo "$keyfinal" >> ${keytxt}/key_${chatuser}.txt
    bot_retorno+="KEY UASADAS [ $numkey_used ] \n"
    bot_retorno+="KEY GENERADAS [ $numkey_gen ]\n"
    bot_retorno+="📀 𝙐𝙗𝙪𝙣𝙩𝙪: 𝟭𝟴, 𝟮𝟬.𝟬𝟰 𝙇𝙏𝙎 ¡𝙍𝙚𝙘𝙤𝙢𝙚𝙣𝙙𝙖𝙙𝙤\n"
    bot_retorno+="<b>☢️ Modo Autodestruccion de Mensaje Activado ✔️</b>\n"
    bot_retorno+="$LINE\n"

    comand_boton "keymen"

    sleep 1h
    msj_del ${message_message_id}
    msj_del ${MSG_id}
}


generar(){
    if [[ $(echo $permited|grep "${chatuser}") = "" ]]; then
        echo ""
        if [[ $(cat ${CID}|grep "${chatuser}") = "" ]]; then
            ShellBot.sendMessage --chat_id $chatuser \
                                --text "$(echo -e "⚠️═ 𝗖𝗢𝗠𝗔𝗡𝗗𝗢 𝗕𝗟𝗢𝗤𝗨𝗘𝗔𝗗𝗢 ═ ⚠️\n▫️ > Sin Acceso VIP \n ❌- KEY CANCELADA -❌ \n")"
        else
            VPSsec=$(date +%s)
            dia="$(cat ${CID}|grep -w "$chatuser"|cut -d'|' -f2)"
            DataSec=$(date +%s --date="$dia")
            [[ "$VPSsec" -gt "$DataSec" ]] && {
                local us="❯ ══━━━━⎊⎊━━━━══ ❮ ️\nUSUARIO ID: <code>$chatuser</code> EXPIRADO \n"
                ShellBot.sendMessage --chat_id ${permited[$id]} \
                                    --text "$(echo -e "$us")" \
                                    --parse_mode html 
                EXPTIME="EXPIRADO"
                rm -rf ${USRdatabase2}/Mensaje_$chatuser.txt &>/dev/null
                rm ${keytxt}/key_${chatuser}.txt &>/dev/null
                sed -i "/$chatuser/d" ${CID}
                [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}         
                ShellBot.sendMessage --chat_id $var \
                                    --text "$(echo -e USUARIO EXPIRADO)" \
                                    --parse_mode html 
                return 0 
            } || {
                EXPTIME="[$(($(($DataSec - $VPSsec)) / 86400))] DIAS"
                gerar_keys
            }
        fi
    else
        gerar_keys
    fi
}


#==> run-cm
function run-cm(){
cmd=("$@")
eval ${cmd[@]} > ~/.runcmd
bot_retorno="\n$(cat ~/.runcmd)\n \nroot@$(wget -qO- ipv4.icanhazip.com):$PWD =>"
msj_fun
rm ~/.runcmd
}
fun_list () {
    rm ${SCPT_DIRC}/*.x.c &> /dev/null
    unset KEY
    KEY="$1"
    #CRIA DIR
    [[ ! -e ${DIR} ]] && mkdir ${DIR}
    #ENVIA ARQS
    i=0
    VALUE+="gerar.sh instgerador.sh http-server.py lista-arq $BASICINSTC"
    for arqx in `ls ${SCPT_DIRC}`; do
        [[ $(echo $VALUE|grep -w "${arqx}") ]] && continue 
        echo -e "[$i] -> ${arqx}"
        arq_list[$i]="${arqx}"
        let i++
    done
    #CRIA KEY
    [[ ! -e ${DIR}/${KEY} ]] && mkdir ${DIR}/${KEY}
    #PASSA ARQS
    unset nombrevalue
    [[ -z ${nombrevalue} ]] && nombrevalue="${message_from_id}" 
    [[ -z ${nombrevalue} ]] && nombrevalue="${callback_query_from_id}"
    if [[ "$(grep -o -i $nombrevalue /etc/adm-db/num-key.cont | wc -l)" -ge "$(cat < /etc/adm-db/limit)" ]]; then
        local bot_retorno="$LINE\n"
        [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
        [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
        bot_retorno+="👤 ●-- Hola  ${firsnme} ${lastnme}\n"
        bot_retorno+="Su 🆔 alcanzó el Límite de KEYS permitidos\n"
        bot_retorno+="▫️ Limite Permitido Vencido: $(cat < /etc/adm-db/limit) \n"
        bot_retorno+="🔴 Generaste 『 $(grep -o -i $nombrevalue /etc/adm-db/num-key.cont | wc -l) 』Keys en el BOT \n"
        bot_retorno+="Espera 12 horas a que se libere o contacta al ADM lo haga\n"
        bot_retorno+="$LINE\n"
        msj_fun
        exit
    else
        echo "$nombrevalue" >> /etc/adm-db/num-key.cont
    fi
    numkey_used=$(grep -o -i $nombrevalue /etc/gerar-sh-log | wc -l)
    numkey_gen=$(grep -o -i $nombrevalue /etc/adm-db/num-key.cont | wc -l)
    #ADM BASIC
    arqslist="$BASICINSTC"
    for arqx in `echo "${arqslist}"`; do
        [[ -e ${DIR}/${KEY}/$arqx ]] && continue #ANULA ARQUIVO CASO EXISTA
        cp ${SCPT_DIRC}/$arqx ${DIR}/${KEY}/
        echo "$arqx" >> ${DIR}/${KEY}/${LIST}
    done
    rm ${SCPT_DIRC}/*.x.c &> /dev/null
    echo "$nombrevalue" > ${DIR}/${KEY}.name
    [[ ! -z $IPFIX ]] && echo "$IPFIX" > ${DIR}/${KEY}/keyfixa
    at now +1 hours <<< "rm -rf ${DIR}/${KEY} && rm -rf ${DIR}/${KEY}.name"
}

ofus() {
    unset server
    server=$(echo ${txt_ofuscatw} | cut -d':' -f1)
    unset txtofus
    number=$(expr length $1)
    for ((i = 1; i < $number + 1; i++)); do
        txt[$i]=$(echo "$1" | cut -b $i)
        case ${txt[$i]} in
            ".") txt[$i]="C" ;;
            "C") txt[$i]="." ;;
            "3") txt[$i]="@" ;;
            "@" ) txt[$i]="3" ;;
            "4") txt[$i]="9" ;;
            "9") txt[$i]="4" ;;
            "6") txt[$i]="P" ;;
            "P") txt[$i]="6" ;;
            "L") txt[$i]="K" ;;
            "K") txt[$i]="L" ;;
        esac
        txtofus+="${txt[$i]}"
    done
    echo "$txtofus" | rev
}


gerar_keyc () {
    MSG_id=$((${message_message_id} + 1 ))
    meu_ip_func
    #Verificador de keys
    unset checkPID_GEN
    checkPID_GEN=$(ps x|grep -v grep|grep "8888")
    [[ ! $checkPID_GEN ]] && checkPID_GEN='️⚠️ ESTADO ⚠️ NO USAR! Esta Key es Invalida🚨' || checkPID_GEN=''
    [[ ! -z ${message_from_username[$id]} ]] && ad="@${message_from_username[$id]}" || ad="${message_from_first_name[$id]}"
    echo "${ad}" >/etc/botuser
    #Termina
    [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
    [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
    unset newresell
    newresell="${USRdatabase2}/Mensaje_$chatuser.txt"
    if [[ ! -e ${newresell} ]]; then
        echo "${firsnme} ${lastnme}" > ${SCPT_DIRC}/message.txt
    else
        echo "$(cat ${newresell})" > ${SCPT_DIRC}/message.txt
    fi

    [[ ! $newresell ]] && credill="By $(cat ${USRdatabase2}/Mensaje_$chatuser.txt)" || credill="By $(cat ${SCPT_DIRC}/message.txt)"

    [[ ! ${keytxt}/key_$chatuser.txt ]] && kg="0" || kg=$(cat ${keytxt}/key_$chatuser.txt | wc -l)

    unset usrLOP nombrevalue nBot nBotSS

    unset nombrevalue
    [[ -z ${nombrevalue} ]] && nombrevalue="${message_from_id}" 
    [[ -z ${nombrevalue} ]] && nombrevalue="${callback_query_from_id}"
    numkey_gen=$(grep -o -i $nombrevalue /etc/adm-db/num-key.cont | wc -l)
    limcont=$(cat /etc/adm-db/limit) 
    [[ "$limcont" -ge "998" ]] && limted="♾️" || limted=$(cat /etc/adm-db/limit)
    [[ "$(( $limcont - $numkey_gen ))" -ge "900" ]] && credres="♾️" || credres=$(( $limcont - $numkey_gen))
    [[ -z $nBot ]] && nBot=$(ShellBot.username)
    valuekey="$(date | md5sum | head -c10)"
    valuekey+="$(echo $(($RANDOM*10))|head -c 5)"
    fun_listc "$valuekey"
    keyfinal=$(ofusc "$IP:8888/$valuekey/$LIST")
    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
                                --text "GENERANDO KEY DARNIX"
    local bot_retorno="┅┅┅⋙💥❯❯ ❯❯❲ BOT GEN ❳❮❮ ❮❮💥⋘┅┅┅ \n"
    bot_retorno+="\n"
    [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
    [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
    [[ -z ${message_chat_tittle} ]] && grupCHAT="" || grupCHAT="ChatID : ${chatuser} "
    bot_retorno+="🔑 KEY GENERADA DARNIX🔑 \n"
    bot_retorno+="\n"
    bot_retorno+="👤 SLOGAN: : $credill\n"
    bot_retorno+="$(cat < /etc/adm-db/resel)\n"
    bot_retorno+="\n"
    bot_retorno+="◈ TOCA EL INSTALADOR ◈:\n"
    bot_retorno+="\n"
    bot_retorno+="<pre>wget https://gitea.com/darnix1/darnix/raw/branch/main/darnix; chmod 777 darnix; ./darnix</pre>\n\n"
    bot_retorno+="\n"
    bot_retorno+="◈ TOCA PARA COPIAR LA KEY ◈\n"
    bot_retorno+="\n"
    bot_retorno+="<code>${keyfinal}</code>\n"
    bot_retorno+="$checkPID_GEN\n"
    bot_retorno+="\n"
    bot_retorno+="$LINE\n"
    echo "$keyfinal" >> ${keytxt}/key_${chatuser}.txt
    bot_retorno+="🔰 KEY GENERADAS [ $numkey_gen ]\n"
    bot_retorno+="📀 𝙐𝙗𝙪𝙣𝙩𝙪: 𝟭𝟴, 𝟮𝟬.𝟬𝟰 𝙇𝙏𝙎 ¡𝙍𝙚𝙘𝙤𝙢𝙚𝙣𝙙𝙖𝙙𝙤\n"
    bot_retorno+="$LINE\n"
    bot_retorno+="<b>☢️ Modo Autodestruccion de Mensaje Activado ✔️</b>\n"

    comand_boton "keymens"

    sleep 1h
    msj_del ${message_message_id}
    msj_del ${MSG_id}
}

  
  
  fun_listc () {
    rm ${SCPT_DIRC}/*.x.c &> /dev/null
    unset KEY
    KEY="$1"
    #CRIA DIR
    [[ ! -e ${DIR} ]] && mkdir ${DIR}
    #ENVIA ARQS
    i=0
    VALUE+="gerar.sh instgerador.sh http-server.py lista-arq $BASICINSTC"
    for arqx in `ls ${SCPT_DIRC}`; do
        [[ $(echo $VALUE|grep -w "${arqx}") ]] && continue 
        echo -e "[$i] -> ${arqx}"
        arq_list[$i]="${arqx}"
        let i++
    done
    #CRIA KEY
    [[ ! -e ${DIR}/${KEY} ]] && mkdir ${DIR}/${KEY}
    #PASSA ARQS
    unset nombrevalue
    [[ -z ${nombrevalue} ]] && nombrevalue="${message_from_id}" 
    [[ -z ${nombrevalue} ]] && nombrevalue="${callback_query_from_id}"
    if [[ "$(grep -o -i $nombrevalue /etc/adm-db/num-key.cont | wc -l)" -ge "$(cat < /etc/adm-db/limit)" ]]; then
        local bot_retorno="$LINE\n"
        [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
        [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
        bot_retorno+="👤 ●-- Hola  ${firsnme} ${lastnme}\n"
        bot_retorno+="Su 🆔 alcanzó el Límite de KEYS permitidos\n"
        bot_retorno+="▫️ Limite Permitido Vencido: $(cat < /etc/adm-db/limit) \n"
        bot_retorno+="🔴 Generaste 『 $(grep -o -i $nombrevalue /etc/adm-db/num-key.cont | wc -l) 』Keys en el BOT \n"
        bot_retorno+="Espera 12 horas a que se libere o contacta al ADM lo haga\n"
        bot_retorno+="$LINE\n"
        msj_fun
        exit
    else
        echo "$nombrevalue" >> /etc/adm-db/num-key.cont
    fi
    numkey_used=$(grep -o -i $nombrevalue /etc/gerar-sh-log | wc -l)
    numkey_gen=$(grep -o -i $nombrevalue /etc/adm-db/num-key.cont | wc -l)
    #ADM BASIC
    arqslist="$BASICINSTC"
    for arqx in `echo "${arqslist}"`; do
        [[ -e ${DIR}/${KEY}/$arqx ]] && continue #ANULA ARQUIVO CASO EXISTA
        cp ${SCPT_DIRC}/$arqx ${DIR}/${KEY}/
        echo "$arqx" >> ${DIR}/${KEY}/${LIST}
    done
    rm ${SCPT_DIRC}/*.x.c &> /dev/null
    echo "$nombrevalue" > ${DIR}/${KEY}.name
    [[ ! -z $IPFIX ]] && echo "$IPFIX" > ${DIR}/${KEY}/keyfixa
    at now +1 hours <<< "rm -rf ${DIR}/${KEY} && rm -rf ${DIR}/${KEY}.name"
}

ofusc() {
    unset server
    server=$(echo ${txt_ofuscatw} | cut -d':' -f1)
    unset txtofus
    number=$(expr length $1)
    for ((i = 1; i < $number + 1; i++)); do
        txt[$i]=$(echo "$1" | cut -b $i)
        case ${txt[$i]} in
            ".") txt[$i]="C" ;;
            "C") txt[$i]="." ;;
            "3") txt[$i]="@" ;;
            "@" ) txt[$i]="3" ;;
            "4") txt[$i]="9" ;;
            "9") txt[$i]="4" ;;
            "6") txt[$i]="P" ;;
            "P") txt[$i]="6" ;;
            "L") txt[$i]="K" ;;
            "K") txt[$i]="L" ;;
        esac
        txtofus+="${txt[$i]}"
    done
    echo "$txtofus" | rev
}


#TERMINA KEYS CON ACCESO 








#EMPIEZA KEYS SINNNNNN ACESSOOOOO

gerar_key () {
    MSG_id=$((${message_message_id} + 1 ))
    meu_ip_fun
    #Verificador de keys
    unset checkPID_GEN
    checkPID_GEN=$(ps x|grep -v grep|grep "8888")
    [[ ! $checkPID_GEN ]] && checkPID_GEN='️⚠️ ESTADO ⚠️ NO USAR! Esta Key es Invalida🚨' || checkPID_GEN=''
    [[ ! -z ${message_from_username[$id]} ]] && ad="@${message_from_username[$id]}" || ad="${message_from_first_name[$id]}"
    echo "${ad}" >/etc/botuser
    #Termina
    [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
    [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
    unset newresell
    newresell="${USRdatabase2}/Mensaje_$chatuser.txt"
    if [[ ! -e ${newresell} ]]; then
        echo "$(cat ${newresell})" > ${SCPT_DIR}/message.txt
    else
        echo "$(cat ${newresell})" > ${SCPT_DIR}/message.txt
    fi

    [[ ! $newresell ]] && credill="By $(cat ${USRdatabase2}/Mensaje_$chatuser.txt)" || credill="By $(cat ${SCPT_DIR}/message.txt)"

    [[ ! ${keytxt}/key_$chatuser.txt ]] && kg="0" || kg=$(cat ${keytxt}/key_$chatuser.txt | wc -l)

    unset usrLOP nombrevalue nBot nBotSS

    unset nombrevalue
    [[ -z ${nombrevalue} ]] && nombrevalue="${message_from_id}" 
    [[ -z ${nombrevalue} ]] && nombrevalue="${callback_query_from_id}"
    numkey_gena=$(grep -o -i $nombrevalue /etc/adm-db/num-keys.cont | wc -l)
    limconta=$(cat /etc/adm-db/limita) 
    [[ "$limconta" -ge "998" ]] && limteda="♾️" || limteda=$(cat /etc/adm-db/limita)
    [[ "$(( $limconta - $numkey_gena ))" -ge "900" ]] && credress="♾️" || credress=$(( $limconta - $numkey_gena))
    [[ -z $nBot ]] && nBot=$(ShellBot.username)
    valuekey="$(date | md5sum | head -c10)"
    valuekey+="$(echo $(($RANDOM*10))|head -c 5)"
    fun_lista "$valuekey"
    keyfinal=$(ofus "$IP:8888/$valuekey/$LIST")
    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
    --text "️GENERANDO KEY DARNIX"
    local bot_retorno="┅┅┅⋙💥❯❯ ❯❯❲ BOT GEN ❳❮❮ ❮❮💥⋘┅┅┅ \n"
    bot_retorno+="\n"
    [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
    [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
    [[ -z ${message_chat_tittle} ]] && grupCHAT="" || grupCHAT="ChatID : ${chatuser} "
    [[ -z ${usrLOP} ]] && bot_retorno+="🆔 ●⸺ [ <tg-spoiler>${nombrevalue}</tg-spoiler> $grupCHAT ] \n"
    bot_retorno+="\n"
    bot_retorno+="👤 SLOGAN: : $credill\n"
    bot_retorno+="$(cat < /etc/adm-db/reselkey)\n"
    bot_retorno+="❗️ Recuerda tener un subdominio valido ❗️\n"
    bot_retorno+="❗️ Puedes obtener uni en duckdns.org ❗️\n"
    bot_retorno+="\n"
    bot_retorno+="◈ TOCA EL INSTALADOR ◈:\n"
    bot_retorno+="\n"
    bot_retorno+="<pre>wget https://gitea.com/darnix1/darnix/raw/branch/main/darnix; chmod 777 darnix; ./darnix</pre>\n\n"
    bot_retorno+="\n"
    bot_retorno+="🔑 Key: (Valida por solo 30 min) \n"
    bot_retorno+="\n"
    bot_retorno+="<code>${keyfinal}</code>\n"
    bot_retorno+="$checkPID_GEN\n"
    bot_retorno+="$LINE\n"
    bot_retorno+="KEY GENERADAS EN 24hrs: [ $credress/$limteda ]\n"
    bot_retorno+="$LINE\n"
    echo "$keyfinal" >> ${keytxt}/key_${chatuser}.txt
    bot_retorno+="📀 𝙐𝙗𝙪𝙣𝙩𝙪: 𝟭𝟴, 𝟮𝟬.𝟬𝟰 𝙇𝙏𝙎 ¡𝙍𝙚𝙘𝙤𝙢𝙚𝙣𝙙𝙖𝙙𝙤\n"
    bot_retorno+="<b>☢️ Modo Autodestruccion de Mensaje Activado ✔️</b>\n"

    bot_retorno+="$LINE\n"

    comand_boton "keylat"

    sleep 1h
    msj_del ${message_message_id}
    msj_del ${MSG_id}

}

fun_lista () {
    rm ${SCPT_DIR}/*.x.c &> /dev/null
    unset KEY
    KEY="$1"
    #CRIA DIR
    [[ ! -e ${DIR} ]] && mkdir ${DIR}
    #ENVIA ARQS
    i=0
    VALUE+="gerar.sh instgerador.sh http-server.py lista-arq $BASICINST"
    for arqx in `ls ${SCPT_DIR}`; do
        [[ $(echo $VALUE|grep -w "${arqx}") ]] && continue 
        echo -e "[$i] -> ${arqx}"
        arq_list[$i]="${arqx}"
        let i++
    done
    #CRIA KEY
    [[ ! -e ${DIR}/${KEY} ]] && mkdir ${DIR}/${KEY}
    #PASSA ARQS
    unset nombrevalue
    [[ -z ${nombrevalue} ]] && nombrevalue="${message_from_id}" 
    [[ -z ${nombrevalue} ]] && nombrevalue="${callback_query_from_id}"
    if [[ "$(grep -o -i $nombrevalue /etc/adm-db/num-keys.cont | wc -l)" -ge "$(cat < /etc/adm-db/limita)" ]]; then
        local bot_retorno="$LINE\n"
        [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
        [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
        bot_retorno+="👤 ●-- Hola  ${firsnme} ${lastnme}\n"
        bot_retorno+="Su 🆔 alcanzó el Límite de KEYS permitidos\n"
        bot_retorno+="▫️ Limite Permitido Vencido: $(cat < /etc/adm-db/limita) \n"
        bot_retorno+="🔴 Generaste 『 $(grep -o -i $nombrevalue /etc/adm-db/num-keys.cont | wc -l) 』Keys en el BOT \n"
        bot_retorno+="Espera 12 horas a que se libere o contacta al ADM lo haga\n"
        bot_retorno+="$LINE\n"
        msj_fun
        exit
    else
        echo "$nombrevalue" >> /etc/adm-db/num-keys.cont
    fi
    numkey_used=$(grep -o -i $nombrevalue /etc/gerar-sh-log | wc -l)
    numkey_gen=$(grep -o -i $nombrevalue /etc/adm-db/num-keys.cont | wc -l)
    #ADM BASIC
    arqslist="$BASICINST"
    for arqx in `echo "${arqslist}"`; do
        [[ -e ${DIR}/${KEY}/$arqx ]] && continue #ANULA ARQUIVO CASO EXISTA
        cp ${SCPT_DIR}/$arqx ${DIR}/${KEY}/
        echo "$arqx" >> ${DIR}/${KEY}/${LIST}
    done
    rm ${SCPT_DIR}/*.x.c &> /dev/null
    echo "$nombrevalue" > ${DIR}/${KEY}.name
    [[ ! -z $IPFIX ]] && echo "$IPFIX" > ${DIR}/${KEY}/keyfixa
    at now +1 hours <<< "rm -rf ${DIR}/${KEY} && rm -rf ${DIR}/${KEY}.name"
}

#Key casita

gerar_cas () {
    MSG_id=$((${message_message_id} + 1 ))
    meu_ip_fun
    #Verificador de keys
    unset checkPID_GEN
    checkPID_GEN=$(ps x|grep -v grep|grep "8888")
    [[ ! $checkPID_GEN ]] && checkPID_GEN='️⚠️ ESTADO ⚠️ NO USAR! Esta Key es Invalida🚨' || checkPID_GEN=''
    [[ ! -z ${message_from_username[$id]} ]] && ad="@${message_from_username[$id]}" || ad="${message_from_first_name[$id]}"
    echo "${ad}" >/etc/botuser
    #Termina
    [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
    [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
    unset newresell
    newresell="${USRdatabase2}/Mensaje_$chatuser.txt"
    if [[ ! -e ${newresell} ]]; then
        echo "$(cat ${newresell})" > ${SCPT_DIR}/message.txt
    else
        echo "$(cat ${newresell})" > ${SCPT_DIR}/message.txt
    fi

    [[ ! $newresell ]] && credill="By $(cat ${USRdatabase2}/Mensaje_$chatuser.txt)" || credill="By $(cat ${SCPT_DIR}/message.txt)"

    [[ ! ${keytxt}/key_$chatuser.txt ]] && kg="0" || kg=$(cat ${keytxt}/key_$chatuser.txt | wc -l)

    unset usrLOP nombrevalue nBot nBotSS

    unset nombrevalue
    [[ -z ${nombrevalue} ]] && nombrevalue="${message_from_id}" 
    [[ -z ${nombrevalue} ]] && nombrevalue="${callback_query_from_id}"
    numkey_gena=$(grep -o -i $nombrevalue /etc/adm-db/num-keys.cont | wc -l)
    limconta=$(cat /etc/adm-db/limita) 
    [[ "$limconta" -ge "998" ]] && limteda="♾️" || limteda=$(cat /etc/adm-db/limita)
    [[ "$(( $limconta - $numkey_gena ))" -ge "900" ]] && credress="♾️" || credress=$(( $limconta - $numkey_gena))
    [[ -z $nBot ]] && nBot=$(ShellBot.username)
    valuekey="$(date | md5sum | head -c10)"
    valuekey+="$(echo $(($RANDOM*10))|head -c 5)"
    fun_listaf "$valuekey"
    keyfinal=$(ofusc "$IP:8888/$valuekey/$LIST")
    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
    --text "GENERANDO KEY V11X"
    local bot_retorno="┅┅┅⋙💥❯❯ ❯❯❲ BOT GEN ❳❮❮ ❮❮💥⋘┅┅┅ \n"
    bot_retorno+="\n"
    [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
    [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
    [[ -z ${message_chat_tittle} ]] && grupCHAT="" || grupCHAT="ChatID : ${chatuser} "
    bot_retorno+="🔑 KEY GENERADA V11X🔑 \n"
    bot_retorno+="\n"
    bot_retorno+="👤 SLOGAN: : $credill\n"
    bot_retorno+="$(cat < /etc/adm-db/resel)\n"
    bot_retorno+="\n"
    bot_retorno+="◈ TOCA EL INSTALADOR ◈:\n"
    bot_retorno+="\n"
    bot_retorno+="<pre>apt update -y; apt list --upgradable; apt upgrade -y; wget --no-check-certificate https://gitea.com/darnix1/darnix/raw/branch/main/LACASITA.sh; chmod 777 LACASITA.sh; ./LACASITA.sh</pre>\n\n"
    bot_retorno+="\n"
    bot_retorno+="◈ TOCA PARA COPIAR LA KEY ◈\n"
    bot_retorno+="\n"
    bot_retorno+="<code>${keyfinal}</code>\n"
    bot_retorno+="$checkPID_GEN\n"
    bot_retorno+="\n"
    bot_retorno+="$LINE\n"
    echo "$keyfinal" >> ${keytxt}/key_${chatuser}.txt
    bot_retorno+="🔰 KEY GENERADAS [ $numkey_gen ]\n"
    bot_retorno+="📀 𝙐𝙗𝙪𝙣𝙩𝙪: 𝟭𝟴, 𝟮𝟬.𝟬𝟰 𝙇𝙏𝙎 ¡𝙍𝙚𝙘𝙤𝙢𝙚𝙣𝙙𝙖𝙙𝙤\n"
    bot_retorno+="$LINE\n"
    bot_retorno+="<b>☢️ Modo Autodestruccion de Mensaje Activado ✔️</b>\n"

    comand_boton "atras2"

    sleep 1h
    msj_del ${message_message_id}
    msj_del ${MSG_id}
}

#casita
fun_listaf () {
    rm ${SCPT_DIRC}/*.x.c &> /dev/null
    unset KEY
    KEY="$1"
    #CRIA DIR
    [[ ! -e ${DIR} ]] && mkdir ${DIR}
    #ENVIA ARQS
    i=0
    VALUE+="gerar.sh instgerador.sh http-server.py lista-arq $BASICINSTC"
    for arqx in `ls ${SCPT_DIRC}`; do
        [[ $(echo $VALUE|grep -w "${arqx}") ]] && continue 
        echo -e "[$i] -> ${arqx}"
        arq_list[$i]="${arqx}"
        let i++
    done
    #CRIA KEY
    [[ ! -e ${DIR}/${KEY} ]] && mkdir ${DIR}/${KEY}
    #PASSA ARQS
    unset nombrevalue
    [[ -z ${nombrevalue} ]] && nombrevalue="${message_from_id}" 
    [[ -z ${nombrevalue} ]] && nombrevalue="${callback_query_from_id}"
    if [[ "$(grep -o -i $nombrevalue /etc/adm-db/num-keys.cont | wc -l)" -ge "$(cat < /etc/adm-db/limita)" ]]; then
        local bot_retorno="$LINE\n"
        [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
        [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
        bot_retorno+="👤 ●-- Hola  ${firsnme} ${lastnme}\n"
        bot_retorno+="Su 🆔 alcanzó el Límite de KEYS permitidos\n"
        bot_retorno+="▫️ Limite Permitido Vencido: $(cat < /etc/adm-db/limita) \n"
        bot_retorno+="🔴 Generaste 『 $(grep -o -i $nombrevalue /etc/adm-db/num-keys.cont | wc -l) 』Keys en el BOT \n"
        bot_retorno+="Espera 12 horas a que se libere o contacta al ADM lo haga\n"
        bot_retorno+="$LINE\n"
        msj_fun
        exit
    else
        echo "$nombrevalue" >> /etc/adm-db/num-keys.cont
    fi
    numkey_used=$(grep -o -i $nombrevalue /etc/gerar-sh-log | wc -l)
    numkey_gen=$(grep -o -i $nombrevalue /etc/adm-db/num-keys.cont | wc -l)
    #ADM BASIC
    arqslist="$BASICINSTC"
    for arqx in `echo "${arqslist}"`; do
        [[ -e ${DIR}/${KEY}/$arqx ]] && continue #ANULA ARQUIVO CASO EXISTA
        cp ${SCPT_DIRC}/$arqx ${DIR}/${KEY}/
        echo "$arqx" >> ${DIR}/${KEY}/${LIST}
    done
    rm ${SCPT_DIRC}/*.x.c &> /dev/null
    echo "$nombrevalue" > ${DIR}/${KEY}.name
    [[ ! -z $IPFIX ]] && echo "$IPFIX" > ${DIR}/${KEY}/keyfixa
    at now +1 hours <<< "rm -rf ${DIR}/${KEY} && rm -rf ${DIR}/${KEY}.name"
}


#keydarnix
autovpsf() {
    MSG_id=$((${message_message_id} + 1 ))
    meu_ip_fun
    #Verificador de keys
    unset checkPID_GEN
    checkPID_GEN=$(ps x|grep -v grep|grep "8888")
    [[ ! $checkPID_GEN ]] && checkPID_GEN='️⚠️ ESTADO ⚠️ NO USAR! Esta Key es Invalida🚨' || checkPID_GEN=''
    [[ ! -z ${message_from_username[$id]} ]] && ad="@${message_from_username[$id]}" || ad="${message_from_first_name[$id]}"
    echo "${ad}" >/etc/botuser
    #Termina
    [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
    [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
    unset newresell
    newresell="${USRdatabase2}/Mensaje_$chatuser.txt"
    if [[ ! -e ${newresell} ]]; then
        echo "$(cat ${newresell})" > ${SCPT_DIR}/message.txt
    else
        echo "$(cat ${newresell})" > ${SCPT_DIR}/message.txt
    fi

    [[ ! $newresell ]] && credill="By $(cat ${USRdatabase2}/Mensaje_$chatuser.txt)" || credill="By $(cat ${SCPT_DIR}/message.txt)"

    [[ ! ${keytxt}/key_$chatuser.txt ]] && kg="0" || kg=$(cat ${keytxt}/key_$chatuser.txt | wc -l)

    unset usrLOP nombrevalue nBot nBotSS

    unset nombrevalue
    [[ -z ${nombrevalue} ]] && nombrevalue="${message_from_id}" 
    [[ -z ${nombrevalue} ]] && nombrevalue="${callback_query_from_id}"
    numkey_gena=$(grep -o -i $nombrevalue /etc/adm-db/num-keys.cont | wc -l)
    limconta=$(cat /etc/adm-db/limita) 
    [[ "$limconta" -ge "998" ]] && limteda="♾️" || limteda=$(cat /etc/adm-db/limita)
    [[ "$(( $limconta - $numkey_gena ))" -ge "900" ]] && credress="♾️" || credress=$(( $limconta - $numkey_gena))
    [[ -z $nBot ]] && nBot=$(ShellBot.username)
    valuekey="$(date | md5sum | head -c10)"
    valuekey+="$(echo $(($RANDOM*10))|head -c 5)"
    fun_listad "$valuekey"
    keyfinal=$(ofusc "$IP:8888/$valuekey/$LIST")
    ShellBot.answerCallbackQuery --callback8_query_id ${callback_query_id[$id]} \
    --text "️GENERANDO KEY DARNIX"
    local bot_retorno="┅┅┅⋙💥❯❯ ❯❯❲ BOT GEN ❳❮❮ ❮❮💥⋘┅┅┅ \n"
    bot_retorno+="\n"
    [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
    [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
    [[ -z ${message_chat_tittle} ]] && grupCHAT="" || grupCHAT="ChatID : ${chatuser} "
    
    [[ -e /etc/menu_ito ]] && nomkey="$(cat /etc/menu_ito)" || nomkey="$(curl -sSL "https://www.dropbox.com/s/z38hj1mz3q9krso/menu_credito")"

    [[ -e ${CIDdir}/ress ]] && echo $nomkey > ${SCPT_DIR}/menu_credito || {
	if [[ ! -e ${CIDRESS}/${chatuser}.conf ]]; then
		echo -e "${firsnme} ${lastnme}" > ${SCPT_DIR}/menu_credito
	else
		cat ${CIDRESS}/${chatuser}.conf > ${SCPT_DIR}/menu_credito
	fi
    }
    adminV="$(less ${SCPT_DIR}/menu_credito)";
    bot_retorno+=" 🛡️ 𝚁𝙴𝚂𝙴𝙻𝙻𝙴𝚁 🛡️ : ${adminV}\n"
    #bot_retorno+="👤 ●⸺ [ ${firsnme} ${lastnme} ] \n"
    [[ -z ${usrLOP} ]] && bot_retorno+="🆔 ●⸺ [ <tg-spoiler>${nombrevalue}</tg-spoiler> $grupCHAT ] \n"
    bot_retorno+="\n"
    bot_retorno+="\n"
    bot_retorno+="$(cat < /etc/adm-db/resel)\n"
    bot_retorno+="❗️ Recuerda tener un subdominio valido ❗️\n"
    bot_retorno+="❗️ Puedes obtener uni en duckdns.org ❗️\n"
    bot_retorno+="\n"
    bot_retorno+="◈ TOCA EL INSTALADOR ◈:\n"
    bot_retorno+="\n"
    bot_retorno+="<pre>wget https://gitea.com/darnix1/darnix/raw/branch/main/darnix; chmod 777 darnix; ./darnix</pre>\n\n"
    bot_retorno+="\n"
    bot_retorno+="◈ TOCA PARA COPIAR LA KEY ◈\n"
    bot_retorno+="\n"
    bot_retorno+="<code>${keyfinal}</code>\n"
    bot_retorno+="$checkPID_GEN\n"
    bot_retorno+="\n"
    bot_retorno+="$LINE\n"
    echo "$keyfinal" >> ${keytxt}/key_${chatuser}.txt
    bot_retorno+="🔰 KEY GENERADAS [ $numkey_gen ]\n"
    bot_retorno+="📀 𝙐𝙗𝙪𝙣𝙩𝙪: 𝟭𝟴, 𝟮𝟬.𝟬𝟰 𝙇𝙏𝙎 ¡𝙍𝙚𝙘𝙤𝙢𝙚𝙣𝙙𝙖𝙙𝙤\n"
    bot_retorno+="$LINE\n"

    comand_boton "atras2"
    sleep 1h
    msj_del ${message_message_id}
    msj_del ${MSG_id}

}


fun_listad () {
    rm ${SCPT_DIR}/*.x.c &> /dev/null
    unset KEY
    KEY="$1"
    #CRIA DIR
    [[ ! -e ${DIR} ]] && mkdir ${DIR}
    #ENVIA ARQS
    i=0
    VALUE+="gerar.sh instgerador.sh http-server.py lista-arq $BASICINST"
    for arqx in `ls ${SCPT_DIR}`; do
        [[ $(echo $VALUE|grep -w "${arqx}") ]] && continue 
        echo -e "[$i] -> ${arqx}"
        arq_list[$i]="${arqx}"
        let i++
    done
    #CRIA KEY
    [[ ! -e ${DIR}/${KEY} ]] && mkdir ${DIR}/${KEY}
    #PASSA ARQS
    unset nombrevalue
    [[ -z ${nombrevalue} ]] && nombrevalue="${message_from_id}" 
    [[ -z ${nombrevalue} ]] && nombrevalue="${callback_query_from_id}"
    if [[ "$(grep -o -i $nombrevalue /etc/adm-db/num-keys.cont | wc -l)" -ge "$(cat < /etc/adm-db/limita)" ]]; then
        local bot_retorno="$LINE\n"
        [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
        [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
        bot_retorno+="👤 ●-- Hola  ${firsnme} ${lastnme}\n"
        bot_retorno+="Su 🆔 alcanzó el Límite de KEYS permitidos\n"
        bot_retorno+="▫️ Limite Permitido Vencido: $(cat < /etc/adm-db/limita) \n"
        bot_retorno+="🔴 Generaste 『 $(grep -o -i $nombrevalue /etc/adm-db/num-keys.cont | wc -l) 』Keys en el BOT \n"
        bot_retorno+="Espera 12 horas a que se libere o contacta al ADM lo haga\n"
        bot_retorno+="$LINE\n"
        msj_fun
        exit
    else
        echo "$nombrevalue" >> /etc/adm-db/num-keys.cont
    fi
    numkey_used=$(grep -o -i $nombrevalue /etc/gerar-sh-log | wc -l)
    numkey_gen=$(grep -o -i $nombrevalue /etc/adm-db/num-keys.cont | wc -l)
    #ADM BASIC
    arqslist="$BASICINST"
    for arqx in `echo "${arqslist}"`; do
        [[ -e ${DIR}/${KEY}/$arqx ]] && continue #ANULA ARQUIVO CASO EXISTA
        cp ${SCPT_DIR}/$arqx ${DIR}/${KEY}/
        echo "$arqx" >> ${DIR}/${KEY}/${LIST}
    done
    rm ${SCPT_DIR}/*.x.c &> /dev/null
    echo "$nombrevalue" > ${DIR}/${KEY}.name
    [[ ! -z $IPFIX ]] && echo "$IPFIX" > ${DIR}/${KEY}/keyfixa
    at now +1 hours <<< "rm -rf ${DIR}/${KEY} && rm -rf ${DIR}/${KEY}.name"
}




#Termina keys sin acceso

comand_boton(){
    if [[ ${comando[1]} = "edit" ]]; then
        edit_msj_boton "botao_$1"
    else
        menu_print "botao_$1"
    fi
}

menu_print () {
    [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}

    ShellBot.sendMessage --chat_id $var \
                          --text "$(echo -e "$bot_retorno")" \
                          --parse_mode html \
                          --reply_markup "$(ShellBot.InlineKeyboardMarkup -b "$1")"
    return 0
}

edit_msj_boton(){
    [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
    [[ ! -z ${callback_query_message_message_id[id]} ]] && message=${callback_query_message_message_id[id]} || message=${return[message_id]}

    ShellBot.editMessageText --chat_id $var \
                              --text "$(echo -e "$bot_retorno")" \
                              --message_id "${message}" \
                              --parse_mode html \
                              --reply_markup "$(ShellBot.InlineKeyboardMarkup -b "$1")"
    return 0
}

download_file () {
    user=User-ID
    [[ -e ${CID} ]] && rm ${CID}
    local file_id
    ShellBot.getFile --file_id ${message_document_file_id[$id]}
    ShellBot.downloadFile --file_path "${return[file_path]}" --dir "${CIDdir}"
    echo "$(cat ${return[file_path]})" >${CID}

    local bot_retorno="ID RESTABLECIDO\n"
    bot_retorno+="$LINE\n"
    bot_retorno+="Se restauro con exito!!\nVolver: /menu\n"
    bot_retorno+="$LINE"
    ShellBot.sendMessage --chat_id "${message_chat_id[$id]}" \
                          --reply_to_message_id "${message_message_id[$id]}" \
                          --text "<i>$(echo -e "$bot_retorno")</i>" \
                          --parse_mode html

    return 0
    rm ${CIDdir}/${return[file_path]}
}

msj_add () {
    ShellBot.sendMessage --chat_id ${1} \
                          --text "$(echo -e "$bot_retor")" \
                          --parse_mode html
}

upfile_fun () {
    [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
    ShellBot.sendDocument --chat_id $var  \
                           --document @${1}
}

msj_fun () {
    [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
    ShellBot.sendMessage --chat_id $var \
                          --text "$(echo -e "$bot_retorno")" \
                          --parse_mode html
    return 0
}

del_msj(){
    msg=(${message_message_id[$id]} $1)
    for i in ${msg[@]}; do
        ShellBot.deleteMessage --chat_id ${message_chat_id[$id]} --message_id "$i"
    done
    return 0
}

msj_del () {
local var
	[[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
		      ShellBot.deleteMessage --chat_id $var --message_id $1 			  
	return 0
}

upfile_src () {
    cp ${CID} $HOME/
    upfile_fun $HOME/User-ID
    rm $HOME/User-ID
}

#REINICIOS DEL BOT 

start_gen () {
    MSG_id=$((${message_message_id} + 1))
    unset PIDGEN
    PIDGEN=$(ps aux | grep -v grep | grep "http-server.sh")
    if [[ ! $PIDGEN ]]; then
        screen -dmS generador /bin/http-server.sh -start
        local bot_retorno=" ✉️ ==== NOTIFICACION ==== ✉️ \n"
        bot_retorno+="$LINE\n"
        bot_retorno+=" Generador: <u>Online</u> ✅\n"
        bot_retorno+="$LINE\n"
        msj_fun
    else
        killall http-server.sh
        local bot_retorno=" ✉️ ==== NOTIFICACION ==== ✉️ \n"
        bot_retorno+="$LINE\n"
        bot_retorno+=" Generador: ⚠️ <u>Offline</u> ❌\n"
        bot_retorno+="$LINE\n"
        msj_fun
    fi
    sleep 5s
    msj_del ${message_message_id}
    msj_del ${MSG_id}
}

restart_genbotx () {
    MSG_id=$((${message_message_id} + 1))
    unset PIDGEN
    PIDGEN=$(ps aux | grep -v grep | grep "http-server.sh")
    [[ ! $PID_GEN ]] && PID_GEN='(APAGADA) ❌' || PID_GEN='(EN LINEA) ✅'

    if [[ $PIDGEN ]]; then
        killall http-server.sh
        sleep 2s
    fi

    screen -dmS generador /bin/http-server.sh -start

    local bot_retorno=" ✉️ ==== NOTIFICACION ==== ✉️ \n"
    bot_retorno+="$LINE\n"
    bot_retorno+=" Generador: <u>Reiniciado</u> ♻️\n"
    bot_retorno+="$LINE\n"

    msj_fun

    sleep 5s
    msj_del ${message_message_id}
    msj_del ${MSG_id}
}

restart_genbot () {
    MSG_id=$((${message_message_id} + 1))
    unset PIDGEN
    PIDGEN=$(ps aux | grep -v grep | grep "http-server.sh")

    local bot_retorno=" ✉️ ==== NOTIFICACION ==== ✉️ \n"
    bot_retorno+="$LINE\n"
    bot_retorno+=" Verificando Estado del proceso NcT...\n"
    bot_retorno+="$LINE\n"
    msj_fun "${bot_retorno}"

    sleep 5s

    local bot_retorno=" ✉️ ==== NOTIFICACION ==== ✉️ \n"
    bot_retorno+="$LINE\n"
    bot_retorno+=" Estado Verificado...\n"
    bot_retorno+="$LINE\n"
    msj_fun "${bot_retorno}"

    sleep 5s

    systemctl is-enabled http-server &> /dev/null
    if [ $? -eq 0 ]; then
        systemctl is-active http-server &> /dev/null
        if [ $? -ne 0 ]; then
            systemctl start http-server
            local bot_retorno=" ✉️ ==== NOTIFICACION ==== ✉️ \n"
            bot_retorno+="$LINE\n"
            bot_retorno+=" Generador: <u>Iniciado</u> ♻️\n"
            bot_retorno+="$LINE\n"
            msj_fun "${bot_retorno}"
        else
            local bot_retorno=" ✉️ ==== NOTIFICACION ==== ✉️ \n"
            bot_retorno+="$LINE\n"
            bot_retorno+=" Generador: <u>Anulacion de Reinicio NcT</u> ✅\n"
            bot_retorno+=" <u>Todos Los Procesos</u> \n"
            bot_retorno+=" <u>Funcionan Correctamente</u> \n"
            bot_retorno+="$LINE\n"
        fi
    else
        killall http-server.sh
        sleep 2s
        screen -dmS generador /bin/http-server.sh -start
        local bot_retorno=" ✉️ ==== NOTIFICACION ==== ✉️ \n"
        bot_retorno+="$LINE\n"
        bot_retorno+=" Generador: <u>Reiniciado</u> ♻️\n"
        bot_retorno+="$LINE\n"
        msj_fun "${bot_retorno}"
    fi

    msj_fun

    sleep 5s

    msj_del ${message_message_id}
    msj_del ${MSG_id}
}


#Termina Bot de reincios



myid_src () {
    MSG_id=$((${message_message_id} + 1))
    [[ -z ${callback_query_from_username} ]] && nUSER=${message_from_username} || nUSER=${callback_query_from_username}
    [[ ! -z $(cat /etc/adm-db/Admin-ID|grep "${chatuser}" ) ]] && {
        bot_retorno="  $LINE\n"
        bot_retorno+="▫️ Hola @${nUSER} \n"
        bot_retorno+="▫️ Bienvenido ADMIN\n"
        bot_retorno+="\n"
        bot_retorno+=" 𝗜𝗗 𝗖𝗔𝗡𝗖𝗘𝗟𝗔𝗗𝗢 ❌\n"
        bot_retorno+="\n"
        bot_retorno+="        No es necesario\n"
        bot_retorno+="        Mostrarte tu ID\n"
        bot_retorno+="$LINE\n"
        bot_retorno+=" <pre>BOT ELIMINANDO MESAJE ${message_message_id} </pre>\n"
        bot_retorno+=" <code>BORRAREMOS ESTE CODE ${MSG_id} </code>\n"
        msj_fun
    } || {
        [[ $(cat ${CID}|grep "${chatuser}" ) = "" ]] && {
            bot_retorno="$LINE\n"
            ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} --text "VERIFICANDO ACCESO VIP"
            [[ -z ${nUSER} ]] && bot_retorno+=" ⚠️ USUARIO SIN ALIAS ⚠️ SIN AUTORIZACION\n" || bot_retorno+="Hola【 @${nUSER} 】, Aviso ❗️ \n"
            bot_retorno+="\n"
            bot_retorno+="🔘 No cuentas con Acceso VIP, adquiere uno . \n"
            bot_retorno+="\n"
            bot_retorno+="❗️ 𝗦𝗜𝗡 𝗖𝗥𝗘𝗗𝗜𝗧𝗢𝗦 𝗗𝗜𝗦𝗣𝗢𝗡𝗜𝗕𝗟𝗘𝗦 ❗️ \n"
            bot_retorno+="🆔 ●--【 <code>${chatuser}</code> 】\n"
            bot_retorno+="Usa el comando /menu \n"
            bot_retorno+="$LINE\n"
            comand_boton "atras"
        } || {
            bot_retorno="  $LINE\n"
            data_user=$(cat ${CID}|grep "${chatuser}" | awk -F "|" '{print $2}')
            data_sec=$(date +%s)
            data_user_sec=$(date +%s --date="$data_user")
            variavel_soma=$(($data_user_sec - $data_sec))
            dias_use=$(($variavel_soma / 86400))
            [[ "$dias_use" -le 0 ]] && dias_use=0 || dias_use=$(($dias_use + 1))
            [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
            [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
            ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} --text "ACCESO VIP VERIFICADO"
            bot_retorno+="👤 ●-- [ ${firsnme} ${lastnme} ] \n"
            bot_retorno+="🆔 ●-- [ <code>${chatuser}</code> ] \n"
            bot_retorno+="\n"
            bot_retorno+="Actualmente tu acceso está activo ✅ \n"
            bot_retorno+="Tu fecha límite de membresía en el BOT es \n"
            datexp=$(date "+%F" -d " + $DIAS days") && valid=$(date '+%C%y-%m-%d' -d " + $DIAS days")
            bot_retorno+="El día $data_user | $(date +%R)\n"
            bot_retorno+="\n"
            bot_retorno+="Para volver al menú pulsa el boton\n"
            comand_boton "atras2"
        }
    }
}

deleteID_src () {
    bot_retorno="/del"
    reply
    listID_src
}

deleteIDS_reply () {
    ids=$(echo ${message_text[$id]} | awk '{print $1}' | sed -e 's/[^a-z0-9 -]//ig')
    idc=$(echo ${message_text[$id]} | awk '{print $3}' | sed -e 's/[^a-z0-9 -]//ig')
    sed -i "/${message_text[$id]}/d" /root/RegBOT/banID
    sed -i "/${message_text[$id]}/d" /root/RegBOT/U_check.txt
    bot_retorno="$LINE\n"
    bot_retorno+=" ID ELIMINADO EXITOSAMENTE!\n"
    bot_retorno+=" ID Eliminado: ${ids}\n"
    bot_retorno+="$LINE\n"
    bot_retor=" 🟢 𝗧𝗨 𝗜𝗗 𝗙𝗨𝗘 𝗗𝗘𝗦𝗕𝗟𝗢𝗤𝗨𝗘𝗔𝗗𝗔 🟢 \n"
    bot_retor+="⚠️ Advertencia ⚠️ [ NO-SPAMEAR ] \n"
    bot_retor+="Ahora puedes volver a usar el menu  \n"
    bot_retor+="Si tienes Dudas, Contacta con el ADM\n"
    bot_retor+="$LINE\n"
    comand_boton "atras"
    msj_fun
    msj_add ${ids}
    upfile_src
}

addIDS_reply () {
    ids=$(echo ${message_text[$id]} | awk '{print $1}' | sed -e 's/[^a-z0-9 -]//ig')
    idc=$(echo ${message_text[$id]} | awk '{print $3}' | sed -e 's/[^a-z0-9 -]//ig')
    echo "${message_text[$id]}" >> /root/RegBOT/banID
    bot_retorno="$LINE\n"
    bot_retorno+=" ID BLOQUEADO EXITOSAMENTE!\n"
    bot_retorno+=" ID Bloqueado: ${ids}\n"
    bot_retorno+="$LINE\n"
    bot_retor="dev \n"
    bot_retor+="$LINE\n"
    comand_boton "atras"
    msj_fun
    msj_add ${ids}
    upfile_src
}

list_IP () {
    unset lsid
    unset idchek
    [[ -z ${idchek} ]] && idchek="${message_from_id}" 
    [[ -z ${idchek} ]] && idchek="${callback_query_from_id}"
    [[ -z "$(cat /etc/adm-db/User-ID | grep ${idchek} )" ]] && {
        [[ "$(cat /etc/adm-db/Admin-ID)" == "${idchek}" ]] && {
            cat /var/www/html/dani/checkIP.log > /tmp/ips
            echo -e " $(cat /tmp/ips | awk '{print $3}' | uniq)" > /tmp/ipchek
            lsid=$(cat -n /tmp/ipchek)
            local bot_retorno=" $LINE\n"
            bot_retorno+='  - ULTIMOS IP´S UNICOS CAPTURADOS  \n'
            bot_retorno+="  -  TIENES $(cat /var/www/html/dani/checkIP.log | wc -l) IP´s CAPTURADAS \n"
            bot_retorno+="$LINE\n"
            bot_retorno+=" ${lsid}\n"
            bot_retorno+="$LINE\n"
        }
    } || {
        cat /var/www/html/dani/checkIP.log | grep "${idchek}" > /tmp/ips
        echo -e " $(cat /tmp/ips | awk '{print $3}' | uniq)" > /tmp/ipchek
        lsid=$(cat -n /tmp/ipchek)
        local bot_retorno=" $LINE\n"
        bot_retorno+='  - ULTIMOS IP´S UNICOS CAPTURADOS  \n'
        bot_retorno+="  -  TIENES $(cat /var/www/html/dani/checkIP.log | grep ${idchek} | wc -l) IP´s CAPTURADAS DE TUS GENERADAS \n"
        bot_retorno+="$LINE\n"
        bot_retorno+=" ${lsid}\n"
        bot_retorno+="$LINE\n"
    }
    msj_fun
}

addID_src () {
    bot_retorno="/add"
    reply
}


deleteIDS_reply () {
    ids=$(echo ${message_text[$id]} | awk '{print $1}' | sed -e 's/[^a-z0-9 -]//ig')
    idc=$(echo ${message_text[$id]} | awk '{print $3}' | sed -e 's/[^a-z0-9 -]//ig')
    sed -i "/${message_text[$id]}/d" /root/RegBOT/banID
    sed -i "/${message_text[$id]}/d" /root/RegBOT/U_check.txt
    bot_retorno="$LINE\n"
    bot_retorno+=" ID ELIMINADO EXITOSAMENTE!\n"
    bot_retorno+=" ID Eliminado: ${ids}\n"
    bot_retorno+="$LINE\n"
    bot_retor=" 🟢 𝗧𝗨 𝗜𝗗 𝗙𝗨𝗘 𝗗𝗘𝗦𝗕𝗟𝗢𝗤𝗨𝗘𝗔𝗗𝗔 🟢 \n"
    bot_retor+="⚠️ Advertencia ⚠️ [ NO-SPAMEAR ] \n"
    bot_retor+="Ahora puedes volver a usar el menu  \n"
    bot_retor+="Si tienes Dudas, Contacta con el ADM\n"
    bot_retor+="xD \n"
    bot_retor+="$LINE\n"
    comand_boton "atras"
    msj_fun
    msj_add ${ids}
    upfile_src
}

addIDS_reply () {
    ids=$(echo ${message_text[$id]} | awk '{print $1}' | sed -e 's/[^a-z0-9 -]//ig')
    idc=$(echo ${message_text[$id]} | awk '{print $3}' | sed -e 's/[^a-z0-9 -]//ig')
    echo "${message_text[$id]}" >> /root/RegBOT/banID
    bot_retorno="$LINE\n"
    bot_retorno+=" ID BLOQUEADO EXITOSAMENTE!\n"
    bot_retorno+=" ID Bloqueado: ${ids}\n"
    bot_retorno+="$LINE\n"
    bot_retor="dev \n"
    bot_retor+="$LINE\n"
    comand_boton "atras"
    msj_fun
    msj_add ${ids}
    upfile_src
}

list_IP () {
    unset lsid
    unset idchek
    [[ -z ${idchek} ]] && idchek="${message_from_id}" 
    [[ -z ${idchek} ]] && idchek="${callback_query_from_id}"
    [[ -z "$(cat /etc/adm-db/User-ID | grep ${idchek} )" ]] && {
        [[ "$(cat /etc/adm-db/Admin-ID)" == "${idchek}" ]] && {
            cat /var/www/html/dani/checkIP.log > /tmp/ips
            echo -e " $(cat /tmp/ips | awk '{print $3}' | uniq)" > /tmp/ipchek
            lsid=$(cat -n /tmp/ipchek)
            local bot_retorno=" $LINE\n"
            bot_retorno+='  - ULTIMOS IP´S UNICOS CAPTURADOS  \n'
            bot_retorno+="  -  TIENES $(cat /var/www/html/dani/checkIP.log | wc -l) IP´s CAPTURADAS \n"
            bot_retorno+="$LINE\n"
            bot_retorno+=" ${lsid}\n"
            bot_retorno+="$LINE\n"
        }
    } || {
        cat /var/www/html/dani/checkIP.log | grep "${idchek}" > /tmp/ips
        echo -e " $(cat /tmp/ips | awk '{print $3}' | uniq)" > /tmp/ipchek
        lsid=$(cat -n /tmp/ipchek)
        local bot_retorno=" $LINE\n"
        bot_retorno+='  - ULTIMOS IP´S UNICOS CAPTURADOS  \n'
        bot_retorno+="  -  TIENES $(cat /var/www/html/dani/checkIP.log | grep ${idchek} | wc -l) IP´s CAPTURADAS DE TUS GENERADAS \n"
        bot_retorno+="$LINE\n"
        bot_retorno+=" ${lsid}\n"
        bot_retorno+="$LINE\n"
    }
    msj_fun
}

addID_src () {
    bot_retorno="/add"
    reply
}

addID_reply () {
    ids=$(echo ${message_text[$id]} | awk '{print $1}' | sed -e 's/[^a-z0-9 -]//ig')
    idc=$(echo ${message_text[$id]} | awk '{print $3}' | sed -e 's/[^a-z0-9 -]//ig')
    valid=$(date '+%C%y-%m-%d' -d " +$idc days")
    [[ $(cat ${CID}|grep "$ids" ) = "" ]] && {
        [[ -e /root/RegBOT/banID ]] && sed -i "/${ids}/d" /root/RegBOT/banID
        echo "${ids} | $valid" >> ${CID}
        echo "${ids} | $(date '+%C%y-%m-%d') | $(date +%R)" >> ${CID}.reg
        bot_retorno=" EL ID FUE REGISTRADO EXITOSAMENTE \n"
        bot_retorno+=" 🆔 : ${ids} | ACEPTADO 🧾\n"
        bot_retorno+="$LINE\n"
        bot_retorno+=" FECHA DE REGISTRO : $(date '+%C%y-%m-%d')|$(date +%R) \n VALIDO HASTA : ${valid}\n"
        bot_retorno+="$LINE\n"
        bot_retorno+="  ✅ ID REGISTRADO EXITOSAMENTE ✅\n"
        bot_retorno+="$LINE\n"
        bot_retorno+="        ⚜ Power ⚜\n"
        unset i
        for i in $(cat /etc/adm-db/User-ID | awk '{print $3}'); do 
            [[ "$(date -d $(date '+%C%y-%m-%d') +%s)" -ge "$(date -d $i +%s)" ]] && {
                for id in $(cat /etc/adm-db/User-ID | grep "$i" | awk '{print $1}' | sed -e 's/[^a-z0-9 -]//ig'); do
                    sed -i "${id}/d" /etc/adm-db/User-ID
                    bot_retor=" ❗️ 𝗦𝗜𝗡 𝗔𝗖𝗖𝗘𝗦𝗢 𝗩𝗜𝗣 ❗️ \n"
                    bot_retor+=" Su acceso vip al bot a finalizado \n"
                    bot_retor+="❌ Fin : $(date '+%C%y-%m-%d') - $(date +%R) \n"
                    bot_retor+=" 🔘 Todavia no cuentas con alguna compra o activacion. \n"
                    bot_retor+=" $LINE\n"
                    msj_add ${id}
                done
            }
        done
        [[ -z ${callback_query_from_username} ]] && nUSER=${message_from_username} || nUSER=${callback_query_from_username}
        [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
        [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
        bot_retor=" 𝗛𝗢𝗟𝗔 𝗕𝗜𝗘𝗡𝗩𝗘𝗡𝗜𝗗𝗢 \n"
        bot_retor+="\n"
        bot_retor+="El ADM ${message_from_first_name[$id]} acepto tu acceso \n"
        bot_retor+="\n"
        bot_retor+="𝗔𝗛𝗢𝗥𝗔 𝗧𝗜𝗘𝗡𝗘𝗦 𝗔𝗖𝗖𝗘𝗦𝗢 𝗩𝗜𝗣 𝗔𝗟 𝗕𝗢𝗧\n"
        bot_retor+="🔘 Inicio : $(date '+%C%y-%m-%d')|$(date +%R) \n🔘 Fin : ${valid}|$(date +%R)\n"
        bot_retor+="\n"
        bot_retor+="🆔 : ${ids} \n"
        bot_retor+="🔘 Autorizado por: ${firsnme} ${lastnm} \n"
        bot_retor+="\n"
        bot_retor+="Digita el comando /menu\n"
        bot_retor+="Adquiere nuevos creditos @$(ShellBot.username)  \n"
        bot_retor+=" $LINE\n"
        msj_fun
        msj_add ${ids}
        upfile_src
    } || {
        bot_retorno="====ERROR====\n"
        bot_retorno+="Este ID ya existe\n"
        bot_retorno+="$LINE\n"
        msj_fun
    }
}

link_src () {
    bot_retorno="$LINE\n"
    bot_retorno+="RESELLER OFICIALES BOTGEN\n"
    bot_retorno+="$LINE\n"
    bot_retorno+="🔰BOT ACTIVACIONES\n"
    bot_retorno+="\n"
    bot_retorno+="🇲🇽 MEXICO\n"
    bot_retorno+="👤 Nombre de usuario @drowkid01 \n"
    bot_retorno+="👤 Nombre de usuario @droidalexander\n"
    bot_retorno+="\n"
    bot_retorno+="$LINE\n"
    comand_boton "atras2"
}


listID_GEN () {
    unset bot_lin
    n=1
    for i in $(cat /root/RegBOT/banID | awk '{print $1}' | sed -e 's/[^a-z0-9 -]//ig'); do 
        idlog=$(cat /root/RegBOT/banID | grep "$i" | awk '{print $3}')
        bot_lin+="  $n] > <tg-spoiler>${i}</tg-spoiler> | $idlog | ${idGEN}\n"
        let n++
    done
    local bot_retorno="$LINE\n"
    bot_retorno+='𝗜𝗗´𝗦 𝗕𝗟𝗢𝗤𝗨𝗘𝗔𝗗𝗢𝗦 𝗣𝗢𝗥 𝗦𝗣𝗔𝗠 \n'
    bot_retorno+="$LINE\n"
    bot_retorno+=" $(echo -e ${bot_lin}) "  #|column -t -s '-')"
    bot_retorno+="$LINE\n"
    comand_boton "atras"
    return 0
}

searchID_reply () {
    searchID=$(cat -n /root/RegBOT/banID | grep "${message_text[$id]}")
    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
    --text "BUSCANDO ID BLOQUEADO"
    bot_retorno="$LINE\n"
    bot_retorno+="𝗠𝗢𝗦𝗧𝗥𝗔𝗡𝗗𝗢 𝗥𝗘𝗦𝗨𝗟𝗧𝗔𝗗𝗢𝗦 𝗗𝗘 𝗕𝗨𝗦𝗤𝗨𝗘𝗗𝗔!\n"
    bot_retorno+=" $LINE\n"
    [[ ! -z ${searchID} ]] && bot_retorno+=" N°${searchID} 🔴 BLOQUEADO \n" || bot_retorno+=" ID NO ENCONTRADO \n"
    comand_boton "atras2"
    return 0
}

listID_src () {
    lsid=$(cat -n ${CID})
    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
    --text "BUSCANDO ID REGISTRADOS"
    local bot_retorno="$LINE\n"
    bot_retorno+="𝗥𝗘𝗦𝗨𝗟𝗧𝗔𝗗𝗢𝗦 𝗗𝗘 🆔 𝗥𝗘𝗚𝗜𝗦𝗧𝗥𝗔𝗗𝗢𝗦 \n"
    bot_retorno+="▫️ 𝗟𝗶𝘀𝘁𝗮 𝗱𝗲 𝗜𝗗 𝗔𝗰𝘁𝗶𝘃𝗼𝘀\n"
    bot_retorno+="$LINE\n"
    bot_retorno+="${lsid}\n"
    bot_retorno+="$LINE\n"
    comand_boton "atras2"
    return 0
}

listIDcup_src () {
    lsid=$(cat -n ${CIDB})
    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
    --text "BUSCANDO ID POR CUPONES"
    local bot_retorno="$LINE\n"
    bot_retorno+="🎟️<b>ID POR CUPONES</b>🎟️\n"
    bot_retorno+="▫️Lista de Usuarios por cupon\n"
    bot_retorno+="$LINE\n"
    bot_retorno+="${lsid}\n"
    bot_retorno+="$LINE\n"
    comand_boton "atras2"
    return 0
}

listkey_src () {
    log=$(cat /etc/gerar-sh-log | awk '{print $1, $2}')
    count=$(echo "$log" | sort | uniq -c)
    count=$(echo "$count" | awk '{printf "%-11s | %2s\n", $1, $2}')
    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
    --text "BUSCANDO KEY USADAS POR ID"
    local bot_retorno="$LINE\n"
    bot_retorno+="𝗥𝗘𝗦𝗨𝗟𝗧𝗔𝗗𝗢𝗦 𝗗𝗘 𝗞𝗘𝗬 𝗨𝗦𝗔𝗗𝗢𝗦 𝗟𝗔𝗧𝗔𝗠 \n"
    bot_retorno+="🔑Key  ——-------— 🆔\n"
    bot_retorno+="$LINE\n"
    bot_retorno+="$count\n"
    bot_retorno+="$LINE\n"
    comand_boton "atras2"
    return 0
}

showHistory() {
    bot_retorno="  $LINE\n"
    data_users=$(grep "${chatuser}" "${CIDC}" | awk -F "|" '{print $2}')
    if [[ -z "${data_users}" ]]; then
        ShellBot.answerCallbackQuery --callback_query_id "${callback_query_id[$id]}" \
        --text "⚠️ NO HAY COMPRAS VENCIDAS REGISTRADAS EN SU ID ⚠️."
        return 0
    fi
    [[ -z "${callback_query_from_first_name}" ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
    [[ -z "${callback_query_from_last_name}" ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
    ShellBot.answerCallbackQuery --callback_query_id "${callback_query_id[$id]}" \
    --text "CONSULTANDO COMPRAS VENCIDAS"
    bot_retorno+="👤 ●-- [ ${firsnme} ${lastnme} ] \n"
    bot_retorno+="🆔 ●-- [ <code>${chatuser}</code> ] \n"
    bot_retorno+="\n"
    bot_retorno+="REGISTRO DE ACTIVACIONES \n"
    bot_retorno+=" \n"
    vencidas=()
    while IFS= read -r data_user; do
        data_sec=$(date +%s)
        data_user_sec=$(date +%s --date="$data_user")
        variavel_soma=$((data_user_sec - data_sec))
        dias_use=$((variavel_soma / 86400))
        [[ "$dias_use" -le 0 ]] && dias_use=0 || dias_use=$((dias_use + 1))
        datexp=$(date "+%F" -d "$data_user + $dias_use day") && valid=$(date '+%C%y-%m-%d' -d "$data_user + $dias_use day")
        vencidas+=("$datexp")
    done <<< "$data_users"
    if [[ ${#vencidas[@]} -gt 0 ]]; then
        bot_retorno+="Registro de Fechas\n"
        if [[ ${#vencidas[@]} -eq 1 ]]; then
            bot_retorno+="Caducado Recientemente:\n"
            bot_retorno+="Día ${vencidas[0]}\n"
            bot_retorno+="\n"
        else
            bot_retorno+="Caducado Recientemente:\n"
            bot_retorno+="Día ${vencidas[${#vencidas[@]}-1]}\n"
            bot_retorno+="\n"
            bot_retorno+="Fechas vencidas anteriores:\n"
            for ((i=${#vencidas[@]}-2; i>=0; i--)); do
                bot_retorno+="Día ${vencidas[$i]}\n"
            done
        fi
    fi
    comand_boton "atras2"
}



ayuda_id(){
    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
    --text "💰 LISTA DE PRECIOS DISPONIBLES"
    local bot_retorno="$LINE\n"
    bot_retorno="$LINE\n"
    bot_retorno+="ɪɴғᴏʀᴍᴀᴄɪᴏɴ sᴏʙʀᴇ ʟᴏs ᴘʀᴇᴄɪᴏs \n"
    bot_retorno+="► PRECIO PAYPAL  ► PRECIO MEXICANO\n"
    bot_retorno+="► 7 DIAS💰1 USD     ► 💰20 MXN\n"
    bot_retorno+="► 13 DIAS💰1.70 USD   ► 💰30 MXN\n"
    bot_retorno+="► 35 DIAS💰2.84 USD ► 💰50 MXN\n"
    bot_retorno+="► 90 DIAS💰4.54USD       ► 💰80 MXN\n"
    bot_retorno+="TRANSFERENCIA\n"
    bot_retorno+="<code>646180192100197089</code>\n"
    bot_retorno+="$LINE\n"
    comand_boton "atras3"
    return 0
}
dnxsub() {
    if [[ $(cat $fsub | grep "$chatuser") ]]; then
        unset sub
        bot_retorno+="<b>TUS SUBDOMINIOS</b>\n"
        for x in $(cat $fsub | grep "$chatuser"); do
            bot_retorno+="🌐 ●⸺[ $(echo $x | awk -F '|' '{print $2}') ⟩ $(echo $x | awk -F "|" '{print $1}') ]\n"
        done
        bot_retorno+="$line\n"
    fi
}

menu_src () {
    bot_retorno="━━━━◢ <b>MENU PRINCIPAL</b> ◣━━━━\n"
   datauser
    [[ -z ${callback_query_from_username} ]] && nUSER=${message_from_username} || nUSER=${callback_query_from_username}
    unset nombrevalue
    [[ -z ${nombrevalue} ]] && nombrevalue="${message_from_id}" 
    [[ -z ${nombrevalue} ]] && nombrevalue="${callback_query_from_id}"
    numkey_used=$(grep -o -i $nombrevalue /etc/gerar-sh-log | wc -l)
    numkey_gena=$(grep -o -i $nombrevalue /etc/adm-db/num-keys.cont | wc -l)
    limconta=$(cat /etc/adm-db/limita) 
    [[ "$limconta" -ge "998" ]] && limteda="♾️" || limteda=$(cat /etc/adm-db/limita)
    [[ "$(( $limconta - $numkey_gena ))" -ge "900" ]] && credress="♾️" || credress=$(( $limconta - $numkey_gena))
    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
             --text "REGRESANDO AL MENU INICIO"
    unset usadas
    usadas="$(cat /etc/http-instas)"
    [[ ! $usadas ]] && k_used="0" || k_used="$usadas"

    if [[ $(cat $fsub|grep "$chatuser") ]]; then
	unset sub
	bot_retorno+="<b><ins>SUBDOMINIOS</ins></b>\n"
	for x in `cat $fsub|grep "$chatuser"`; do
		bot_retorno+="🌐 ●⸺[ $(echo $x|awk -F '|' '{print $2}') ⟩⟩⟩ $(echo $x|awk -F "|" '{print $1}') ]\n"
	done
	bot_retorno+="$line\n"
     fi
    if [[ $(echo $permited|grep "${chatuser}") = "" ]]; then
        if [[ $(cat ${CID}|grep "${chatuser}") = "" ]]; then
            [[ -e /root/RegBOT/banID ]] && idBAN=$(cat /root/RegBOT/banID) || idBAN=""
            [[ -z "$(echo $idBAN | grep "${chatuser}")" ]] && {
                local bot_retorno="$LINE\n"
                bot_retorno="━━━━◢ <b>MENU PRINCIPAL</b> ◣━━━━\n"
                datauser
                bot_retorno+="🌐 |-- Instalaciones Totales [ $k_used ] \n"
                bot_retorno+="\n"
                bot_retorno+="🗓️ TOTAL DIAS DE ACCESO\n"
                bot_retorno+="[ ❌ 𝗦𝗶𝗻 𝗮𝗰𝗰𝗲𝘀𝗼 𝗩𝗜𝗣 ❌ ]\n"
                bot_retorno+="📅 VIGENCIA DEL ACCESO\n"
                bot_retorno+="[ ❌ 𝗦𝗶𝗻 𝗮𝗰𝗰𝗲𝘀𝗼 𝗩𝗜𝗣 ❌ ]\n"
                bot_retorno+="\n"
                bot_retorno+="Hola :${firsnme} ${lastnme} \n"
                bot_retorno+="\n"
                bot_retorno+="🔑Total Instalado:『 $numkey_used 』\n"
                bot_retorno+="⚠️Limite Actual (24hrs): [ $credress/$limteda ]\n"
                bot_retorno+="🔘 Recuerda No hacer 𝗦𝗣𝗔𝗠 \n"
                bot_retorno+="$LINE\n"
                comand_boton "user1"
                return 0
            } || {
                bot_retorno="$LINE\n"
                bot_retorno+="     ⚠️ 𝗦𝗨 𝗜𝗗 𝗙𝗨𝗘 𝗕𝗔𝗡𝗘𝗔𝗗𝗢 ⚠️ \n"
                bot_retorno+="\n"
                [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
                [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
                bot_retorno+="👤 ●-- [ ${firsnme} ${lastnme} ] \n"
                bot_retorno+="🆔 ●-- [ <code>${chatuser}</code> ] \n"
                bot_retorno+="\n"
                bot_retorno+="❗️ [ SPAM-BOT ] Detected ❗️ \n"
                bot_retorno+="$LINE\n"
                comand_boton "dex"
                return 0
            }
        else
            VPSsec=$(date +%s)
            dia="$(cat ${CID}|grep -w "$chatuser"|cut -d'|' -f2)"
            DataSec=$(date +%s --date="$dia")
            [[ "$VPSsec" -gt "$DataSec" ]] && {
                local us="❯ ══━━━━⎊⎊━━━━══ ❮ ️\nUSUARIO 🆔: <code>$chatuser</code> EXPIRADO\n"
                ShellBot.sendMessage --chat_id ${permited[$id]} \
                --text "$(echo -e "$us")" \
                --parse_mode html 
                EXPTIME="EXPIRADO"
                rm -rf ${USRdatabase2}/Mensaje_$chatuser.txt &>/dev/null
                rm ${keytxt}/key_${chatuser}.txt &>/dev/null
                sed -i "/$chatuser/d" ${CID}
                [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}         
                ShellBot.sendMessage --chat_id $var \
                --text "$(echo -e USUARIO EXPIRADO)" \
                --parse_mode html 
                return 0 
            } || {
                EXPTIME="[$(($(($DataSec - $VPSsec)) / 86400))] DIAS"
                [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
                [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
                unset creditos
                creditos="$(cat /etc/adm-db/Creditos/Mensaje_$chatuser.txt)"
                [[ ! $creditos ]] && credi="Defaul: ${firsnme} ${lastnme}" || credi="Personal: $creditos"

                unset PID_GEN
                PID_GEN=$(ps x|grep -v grep|grep "http-server.sh")
                [[ ! $PID_GEN ]] && PID_GEN='(APAGADA) ❌' || PID_GEN='(EN LINEA) ✅'
                unset checkPID_GEN
                checkPID_GEN=$(ps x|grep -v grep|grep "8888")
                [[ ! $checkPID_GEN ]] && checkPID_GEN='⚠️ ESTADO!! BotGen Critico ⚠' || checkPID_GEN='🔥 Servicios En Estado Optimo ✅'
                data_user=$(cat ${CID}|grep "${chatuser}" | awk -F "|" '{print $2}')
                data_sec=$(date +%s)
                data_user_sec=$(date +%s --date="$data_user")
                variavel_soma=$(($data_user_sec - $data_sec))
                dias_use=$(($variavel_soma / 86400))
                [[ "$dias_use" -le 0 ]] && dias_use=0 || dias_use=$(($dias_use + 1))

                unset usadas
                usadas="$(cat /etc/http-instas)"
                [[ ! $usadas ]] && k_used="0" || k_used="$usadas"
                numkey_used=$(grep -o -i $nombrevalue /etc/gerar-sh-log | wc -l)
                numkey_gen=$(grep -o -i $message_chat_id /etc/adm-db/num-key.cont | wc -l)
                unset nombrevalue
                [[ -z ${nombrevalue} ]] && nombrevalue="${message_from_id}" 
                [[ -z ${nombrevalue} ]] && nombrevalue="${callback_query_from_id}"
                numkey_gen=$(grep -o -i $nombrevalue /etc/adm-db/num-key.cont | wc -l)
                limcont=$(cat /etc/adm-db/limit) 
                [[ "$limcont" -ge "998" ]] && limted="♾️" || limted=$(cat /etc/adm-db/limit)
                [[ "$(( $limcont - $numkey_gen ))" -ge "900" ]] && credres="🎊 Usted tiene keys Ilimitados" || credres="⚠️Keys Restantes a Generar: $(( $limcont - $numkey_gen))"
                [[ ! ${keytxt}/key_$chatuser.txt ]] && kg="0" || kg=$(cat ${keytxt}/key_$chatuser.txt | wc -l)
                ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
                --text "VOLVIENDO AL MENU INICIO"
                local bot_retorno="$LINE\n"
                bot_retorno="━━━━◢ <b>MENU PRINCIPAL</b> ◣━━━━\n"
                datauser
                dnxsub
                bot_retorno+="🗓 <b>TOTAL DIAS DE ACCESO</b>\n"
                bot_retorno+="🔘 |-- Días Restantes $EXPTIME \n"
                bot_retorno+="📅 <b>TU ACCESO CADUCA</b> \n"
                bot_retorno+="🔘 |-- El dia [ $data_user ] \n"
                bot_retorno+="\n"
                bot_retorno+="📳 <b>Notificacion del BOT</b> \n"
                bot_retorno+="$(cat < /etc/adm-db/resell)\n"
                bot_retorno+="$checkPID_GEN\n"
                bot_retorno+="\n"
                bot_retorno+="📡 |-- BOT Status [ $PID_GEN ]\n"
                bot_retorno+="🧑‍💻 Reseller $credi\n"
                bot_retorno+="🔐 |-- Total Key Usadas:『 $numkey_used 』\n"
                bot_retorno+="🔑 |-- Total Key Generadas: [ $kg ]\n"
                bot_retorno+="🔰 $credres \n"
                comand_boton "user"
                return 0
            }
        fi
    else
        vv=$(ps x|grep -v grep|grep "veri")
        [[ ! $vv ]] && ve="[ DESACTIVADO ]" || ve="[ ACTIVADO ]"
        unset checkPID_GEN
        checkPID_GEN=$(ps x|grep -v grep|grep "8888")
        [[ ! $checkPID_GEN ]] && checkPID_GEN='⚠️ ESTADO!! BotGen Critico ⚠' || checkPID_GEN='🔥 Servicios En Estado Optimo ✅'
        [[ ! -z ${message_from_username[$id]} ]] && ad="@${message_from_username[$id]}" || ad="${message_from_first_name[$id]}"
        echo "${ad}" >/etc/botuser
        unset PID_GEN
        PID_GEN=$(ps x|grep -v grep|grep "http-server.sh")
        [[ ! $PID_GEN ]] && PID_GEN='(APAGADA) ❌' || PID_GEN='(EN LINEA) ✅'
        [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
        [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
        unset creditos
        creditos="$(cat /etc/adm-db/Creditos/Mensaje_$chatuser.txt)"
        [[ ! $creditos ]] && credi="Defaul: ${firsnme} ${lastnme}" || credi="Personal: $creditos"
        $(cat /etc/adm-db/User-ID| wc -l)
        unset usadas
        usadas="$(cat /etc/http-instas)"
        [[ ! $usadas ]] && k_used="0" || k_used="$usadas"
        [[ ! ${keytxt}/key_$chatuser.txt ]] && kg="0" || kg=$(cat ${keytxt}/key_$chatuser.txt | wc -l)
        num_ips=${#user_connections[@]}
        ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
             --text "RETORNANDO AL MENU INICIO"
        local bot_retorno="$LINE\n"
        bot_retorno="━━━━◢ <b>MENU PRINCIPAL</b> ◣━━━━\n"
        datauser
        dnxsub
        bot_retorno+="🆔 |-- USUARIOS 𝗩𝗜𝗣 ACTIVOS: $(cat /etc/adm-db/User-ID| wc -l)\n"
        bot_retorno+="🟢 |-- BOT STATUS:  $PID_GEN \n"
        bot_retorno+="📵 |-- AUTO-DEL:  $ve \n"
        bot_retorno+="🔔NOTY BOT USUARIOS \n"
        bot_retorno+="$checkPID_GEN\n"
        bot_retorno+="$(cat < /etc/adm-db/resell)\n"
        bot_retorno+="🔐 |-- Key Activas Sin Usar 『 $(ls /etc/http-shell/ | grep name | wc -l) 』 🗝️ \n"
        bot_retorno+="🌐 |-- Inst. Totales del SCRIPT [ $k_used ] \n"
        bot_retorno+="🔑 |-- Keys Generadas del ADM [ $kg ] \n"
        bot_retorno+="👤 |-- Reseller $credi\n"
        bot_retorno+="🔌 |--  CONTROL REMOTO $num_ips\n"
        [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
        [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
        bot_retorno+="🔰 |-- ADMIN: ${firsnme} ${lastnme} \n"
        bot_retorno+="$LINE\n"
        comand_boton "conf"
        return 0
    fi	
}


mensajecre() {
    error_fun () {
        local bot_retorno="$LINE\n"
        bot_retorno+="USAR EL COMANDO DE ESTA MANERA\n"
        bot_retorno+="$LINE\n"
        bot_retorno+="Ejemplo: /resell  @d\n"
        bot_retorno+="$LINE\n"
        ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
                                --text "<i>$(echo -e "$bot_retorno")</i>" \
                                --parse_mode html
        return 0
    }

    [[ -z $1 ]] && error_fun && return 0

    echo "$1" > ${USRdatabase2}/Mensaje_$chatuser.txt
    bot_retorno="$LINE\n"
    bot_retorno+="✅Creditos Cambiado ✅\n"
    bot_retorno+="$LINE\n"
    bot_retorno+="Nuevo Reseller: $1\nPARA REGRESAR /menu\n"
    bot_retorno+="$LINE"

    [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
    ShellBot.sendMessage --chat_id $var \
                            --text "<i>$(echo -e "$bot_retorno")</i>" \
                            --parse_mode html

    return 0
}

[[ -d /root/RegBOT ]] || mkdir /root/RegBOT                  
autori() {
    MSG_id=$((${message_message_id} + 1 ))
    [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
    [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
    [[ -z ${callback_query_from_username} ]] && nUSER=${message_from_username} || nUSER=${callback_query_from_username}
    [[ -e /root/RegBOT/U_check.txt ]] && n_soli=$(cat /root/RegBOT/U_check.txt | grep ${chatuser} | wc -l) || n_soli=1
    [[ $n_soli < 2 ]] && {
        echo "${chatuser}" >> /root/RegBOT/U_check.txt
        bot_retor="$LINE\n"
        bot_retor+=" Cliente 『 ${firsnme} ${lastnme} 』Solicita Autorización\n"
        [[ -z ${nUSER} ]] && bot_retor+=" ⚠️ USUARIO SIN ALIAS ⚠️\n" || bot_retor+=" <u> ALIAS</u>: @${nUSER} CON $n_soli INTENTO\n"
        bot_retor+="$LINE\n"
        bot_retor+=" EJEMPLO $MSG_id <tg-spoiler>${chatuser}</tg-spoiler> | <u>DIAS</u> \n"
        bot_retor+=" O SOLO DA CLICK AQUI 👉 /add , LUEGO COPIA ALGUNO DE ABJO\n"
        bot_retor+=" COPIA EL ID 👉 ♨️ <code>${chatuser}</code> ♨️\n"
        bot_retor+="$LINE\n"
        bot_retor+=" ANTES DE LA AUTORIZACION VERIFICAR PAGO\n"
        bot_retor+="$LINE\n"

        while IFS= read -r id; do
            msj_add "$id"
        done < "${CIDdir}/Admin-ID"
        bot_retor+="$LINE\n"
        bot_retorno+="🆔 ●-- 【 <code>${chatuser}</code> 】\n"
        bot_retorno+="\n"
        [[ -z ${nUSER} ]] && bot_retorno+=" ❌ Añada un Alias Para no Banearte ❌ \n" || bot_retorno+=" 𝗦𝗼𝗹𝗰𝗶𝘁𝘂𝗱 𝗲𝗻𝘃𝗶𝗮𝗱𝗮 𝗮𝗹 𝗔𝗗𝗠 $(cat < /etc/ADM-db/resell)\n📌 Aprobación en proceso ⌛\n"
        [[ -z ${nUSER} ]] && bot_retorno+="   Imposible verificar su ID \n  Su ${n_soli} Solicitud es Invalida \n" || bot_retorno+=" Esta es su  ${n_soli} Solicitud \n"
        bot_retorno+="\n"
        [[ -z ${nUSER} ]] && bot_retorno+=" SU ID FUE ENVIADO CON ADVERTENCIA (POSIBLE BANEO DE ID) ⚠️\n" || bot_retorno+="      ✅ ID ENVIADO EXITOSAMENTE ✅\n"
        bot_retorno+="$LINE\n"
        bot_retorno+=" ENVIE SU COMPROBANTE DE PAGO\n"
        bot_retorno+="🔘 Evita hacer spam en el BOT\n"
        bot_retorno+="🔘 De lo contrario se anulará tu solicitud \n"
        bot_retorno+="$LINE\n"
        comand_boton "atras"
    } || {
        bot_retorno="$LINE\n"
        bot_retorno+="🆔 ●-- 【 <code>${chatuser}</code> 】 \n"
        #bot_retorno+="$LINE\n"
        [[ -z ${nUSER} ]] && bot_retorno+=" ⚠️ USUARIO SIN ALIAS ⚠️\n" || bot_retorno+=" <u>🆔 ●⸺ Hola </u>: @${nUSER} \n"
        [[ -z ${nUSER} ]] && bot_retorno+=" ⚠️ AÑADA UN ALIAS PARA PODER SOLICITAR DE MANERA EXITOSA ⚠️\n" || bot_retorno+="𝗜𝗻𝘁𝗲𝗻𝘁𝗼𝘀 𝗱𝗲 𝗦𝗼𝗹𝗶𝗰𝗶𝘁𝘂𝗱  ${n_soli} $(cat < /etc/ADM-db/resell)\n"
        [[ -z ${nUSER} ]] && bot_retorno+="   IMPOSIBLE VERIFICAR ID SIN ALIAS\n  SU ${n_soli} SOLITUD ES INVALIDA \n" || bot_retorno+="Su 🆔 No fue recibido por el ADM \n"
        bot_retorno+="     🔴 𝗧𝗨 𝗜𝗗 𝗙𝗨𝗘 𝗕𝗟𝗢𝗤𝗨𝗘𝗔𝗗𝗔 🔴 \n"
        bot_retorno+="$LINE\n"
        echo "${chatuser}" >> /root/RegBOT/banID
        #bot_retorno+="        ⚜ Power botgen ⚜\n"
        bot_retorno+="$LINE\n"
        msj_fun
    }
}

ipgeo_reply() {
    local ip=$(echo "${message_text[$id]}" | awk -F '|' '{print $1}' | awk '{print $1}')
    local chat_id="${message_chat_id[$id]}"
    
    local bot_retorno="Datos de la IP: $ip\n\n"
    
    # Obtener información de la IP utilizando ipinfo.io
    local info_ip=$(curl -s "https://ipinfo.io/$ip/json")

    if [[ -n $info_ip ]]; then
        # Analizar y formatear la respuesta JSON
        local ciudad=$(echo "$info_ip" | jq -r '.city')
        local pais=$(echo "$info_ip" | jq -r '.country')
        local proveedor=$(echo "$info_ip" | jq -r '.org')
        local latitud=$(echo "$info_ip" | jq -r '.loc' | awk -F ',' '{print $1}')
        local longitud=$(echo "$info_ip" | jq -r '.loc' | awk -F ',' '{print $2}')
        local fecha_escaneo=$(date +'%Y-%m-%d %H:%M:%S')

        bot_retorno+="Ciudad: $ciudad\n"
        bot_retorno+="País: $pais\n"
        bot_retorno+="Proveedor: $proveedor\n"
        bot_retorno+="Latitud: $latitud\n"
        bot_retorno+="Longitud: $longitud\n"
        bot_retorno+="Fecha de escaneo: $fecha_escaneo\n"
    else
        bot_retorno+="❌ Error: No se pudo obtener información de la IP. ❌\n"
    fi
    
    ShellBot.sendMessage --chat_id "$chat_id" --text "$bot_retorno"
}

deleteID_reply2 () {
    rm -rf ${USRdatabase2}/Mensaje_${message_text[$id]}.txt &>/dev/null
    rm -rf ${keytxt}/key_${message_text[$id]}.txt &>/dev/null
    sed -i "/${message_text[$id]}/d" ${CID}
    local bot_retorno="$LINE\n"
    bot_retorno+="🔴 ●-- 𝗜𝗗 𝗘𝗟𝗜𝗠𝗜𝗡𝗔𝗗𝗢 𝗖𝗢𝗡 𝗘𝗫𝗜𝗧𝗢\n"
    bot_retorno+="🆔 ●-- : ${message_text[$id]}\n"
    bot_retorno+="$LINE\n"

    comand_boton "atras2"
}


rmid(){
    [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
    ShellBot.sendMessage --chat_id $var \
        --text "𝙄𝙉𝙂𝙍𝙀𝙎𝙀 𝙀𝙇 𝙄𝘿 𝘿𝙀𝙇 𝙐𝙎𝙐𝘼𝙍𝙄𝙊" \
        --reply_markup "$(ShellBot.ForceReply)"
}

newid(){
    [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
    ShellBot.sendMessage --chat_id $var \
        --text "𝙄𝙉𝙂𝙍𝙀𝙎𝙀 𝙀𝙇 𝙉𝙐𝙀𝙑𝙊 𝙄𝘿" \
        --reply_markup "$(ShellBot.ForceReply)"
}

mensaje(){
    [[ $(cat ${SCPT_DIR}|grep "${message_text[$id]}") = "" ]]
    echo "${message_text[$id]}" > ${USRdatabase2}/Mensaje_$chatuser.txt
    local bot_retorno="$LINE\n"
    bot_retorno+="🟢 ●-- 𝗥𝗘𝗦𝗘𝗟𝗟𝗘𝗥 𝗔𝗚𝗥𝗘𝗚𝗔𝗗𝗢 \n"
    bot_retorno+="$LINE\n"
    bot_retorno+="▫️ Nuevo Reseller: ${message_text[$id]}\nVolver: /menu\n"
    bot_retorno+="$LINE"
    
    [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
    ShellBot.sendMessage --chat_id $var \
                            --text "<i>$(echo -e "$bot_retorno")</i>" \
                            --parse_mode html
    return 0
}

newres(){
    [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
    --text "✅ AGREGANDO RESELLER"
    ShellBot.sendMessage --chat_id $var \
        --text "☟INGRESE SU RESELLER ABAJO☟" \
        --reply_markup "$(ShellBot.ForceReply)"
}

newip(){
    [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
    --text "✅  INGRESA TU IP REMOTO "
    ShellBot.sendMessage --chat_id $var \
        --text "CONEXION REMOTA A VPS \n\n Requiere de informacion para la conexion remota\n\n IP|PUERTO|USUARIO|CONTRASEÑA\n\nEjemplo ✅  \n142.93.122.215|22|root|Dans862Jjw "

    ShellBot.sendMessage --chat_id $var \
        --text "☟INGRESE SU IP☟" \
        --reply_markup "$(ShellBot.ForceReply)"
}

idban(){
    [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
    ShellBot.sendMessage --chat_id $var \
        --text "INGRESE ID A BANEAR" \
        --reply_markup "$(ShellBot.ForceReply)"
}

ipgeo(){
    [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
    ShellBot.sendMessage --chat_id $var \
        --text "INGRESE SU IP" \
        --reply_markup "$(ShellBot.ForceReply)"
}

cupon() {
    [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
    if [[ $cupon_activado == true ]]; then
        ShellBot.sendMessage --chat_id $var \
            --text "INGRESE SU CUPON" \
            --reply_markup "$(ShellBot.ForceReply)"
    else
        ShellBot.sendMessage --chat_id $var \
            --text "🥲 Me encuentro Desactivado, contacta al ADM"
    fi
}


remoip(){
    [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
    --text "✅  INGRESA TU IP REMOTO "
    ShellBot.sendMessage --chat_id $var \
        --text "CONEXION REMOTA A VPS \n\n Requiere de informacion para la conexion remota\n\n IP|USUARIO|CONTRASEÑA\n\nEjemplo ✅  \nip|root|pass\n"

    ShellBot.sendMessage --chat_id $var \
        --text "INGRESE SU IP REMOTO" \
        --reply_markup "$(ShellBot.ForceReply)"
}

passip(){
    [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
    --text "✅  INGRESA TU IP REMOTO "
    ShellBot.sendMessage --chat_id $var \
        --text "CAMBIAR PASS A VPS \n\n Ingresa como el siguiente ejem \n\n IP|USUARIO|PASSWORD|NUEVOPASS \n"

    ShellBot.sendMessage --chat_id $var \
        --text "INGRESE SUS DATOS" \
        --reply_markup "$(ShellBot.ForceReply)"
}

autodel_id() {
    if [[ $(echo $permited|grep "${chatuser}") = "" ]]; then
        local bot="•────•──────────•────•\n"
        bot+="            Usted no tiene permiso para usar este comando\n"
        bot+="•────•──────────•────•\n"
        [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
        ShellBot.sendMessage --chat_id $var \
            --text "$bot" \
            --parse_mode html
        return 0
    else
        local bot=" =             𝘼𝙐𝙏𝙊-𝘿𝙀𝙇 𝙄𝘿'𝙎=\n"
        
        local verificar
        PIDV=$(ps aux|grep -v grep|grep "veri")
        if [[ -z $PIDV ]]; then
            echo ""
            screen -dmS verificar /etc/adm-db/veri &
            verificar="𝘼𝘾𝙏𝙄𝙑𝘼𝘿𝙊  --  𝘾𝙊𝙉 𝙀𝙓𝙄𝙏𝙊\n            𝙖𝙪𝙩𝙤-𝙞𝙣𝙞𝙘𝙞𝙤 𝙘𝙖𝙙𝙖 1𝙝"
        else
            kill -9 $(ps aux |grep -v grep |grep -w "veri"|grep dmS|awk '{print $2}') &>/dev/null
            kill -9 $(ps aux |grep -v grep |grep -w "verificar"|grep dmS|awk '{print $2}') &>/dev/null
            verificar="𝘿𝙀𝙎𝘼𝘾𝙏𝙄𝙑𝘼𝘿𝙊  --  𝘾𝙊𝙉 𝙀𝙓𝙄𝙏𝙊"
        fi
        bot+="•────•──────────•────•\n"
        bot+="            $verificar\n"
        bot+="•────•──────────•────•\n"
        [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
        ShellBot.sendMessage --chat_id $var \
            --text "$bot" \
            --parse_mode html
        return 0
    fi
}

rm_resell(){
    rm ${USRdatabase2}/Mensaje_$chatuser.txt
    [[ -z ${USRdatabase2}/Mensaje_$chatuser.txt ]] && rs="$(cat ${USRdatabase2}/Mensaje_$chatuser.txt)" || rs="Sin-Reseller"
    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
        --text "❌ ELIMINANDO RESELLER"
    bot_retorno="$LINE\n"
    bot_retorno+="🔴 ●--  𝗥𝗘𝗦𝗘𝗟𝗟𝗘𝗥 𝗘𝗟𝗜𝗠𝗜𝗡𝗔𝗗𝗢\n"
    bot_retorno+="▫️ Verificador de reseller: ${rs}\nVolver Pulsa /menu\n"
    bot_retorno+="$LINE\n"
    [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
    ShellBot.sendMessage --chat_id $var \
        --text "<i>$(echo -e "$bot_retorno")</i>" \
        --parse_mode html
    return 0
}



addADM_reply () {
  [[ $(cat /etc/adm-db/Admin-ID | grep "${message_text[$id]}") = "" ]] && {
    echo "${message_text[$id]}" >> /etc/adm-db/Admin-ID

    bot_retorno="$LINE\n"
    bot_retorno+="*ID agregado *\n"
    bot_retorno+="$LINE\n"
    bot_retorno+="$LINE\n"
    bot_retorno+="New ID: ${message_text[$id]}\n"
    bot_retorno+="$LINE"

    bot_retor="$LINE\n"
    bot_retor+="Bienvenido Nuevo Administrador\n"
    bot_retor+="❌ NO REGISTRAR  ID DUPLICADOS ❌\n"
    bot_retor+="\n"
    bot_retor+="EL ADMIN principal puede controlar sus Altas\n"
    bot_retor+="Para Comenzar pulsa /menu"
    bot_retor+="$LINE\n"
    
    msj_fun
    msj_add ${message_text[$id]}
    upfile_src
  } || {
    bot_retorno="====ERROR====\n"
    bot_retorno+="Este ID ya existe\n"
    bot_retorno+="$LINE\n"
    msj_fun
  }
}

cupon_activado=false

cupon_reply() {
    # Verificar si el botón está activado
 if [[ $cupon_activado == true ]]; then
  local github_url="https://raw.githubusercontent.com/DanssBot/Generador-BOT/main/cup.txt"
  local cupon_ingresado="${message_text[$id]}"
  
  # Obtener el ID de usuario de manera alternativa
  local user_id="${callback_query_message_chat_id[$id]:-${message_chat_id[$id]}}"
  
  
  # Descargar los cupones válidos del archivo en GitHub
  cupones_validos=$(curl -s "$github_url")

  # Verificar si el cupón ya ha sido canjeado previamente
  if grep -q "^${cupon_ingresado}$" /etc/adm-db/Cupones-Canjeados; then
    # El cupón ya ha sido canjeado anteriormente
    bot_retorno="🎟️CUPON INVALIDO🎟️.\n"
    bot_retorno+="\n"
    bot_retorno+="⚠️ No canjeado ⚠️\n"
    bot_retorno+="Cupon usado anteriormente\n"
    [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
    [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
    bot_retorno+="👤 ●-- [ ${firsnme} ${lastnme} ] \n"
    bot_retorno+="🆔 ●-- [ <code>${chatuser}</code> ] \n"
    bot_retorno+="\n"
    bot_retorno+="$LINE\n"
    
    ## Contar cuántos usuarios han intentado usar el mismo cupón
    usuarios_que_intentaron=$(grep -c "^${cupon_ingresado}$" /etc/adm-db/Intentos-Canje)

    # Envía el mensaje al administrador (debes proporcionar el ID del administrador)
    send_message_to_admin "${mensaje_admin}"
    msj_fun
    return
  fi

  # Buscar el cupón ingresado en la lista de cupones válidos
  local fecha_expiracion=""
  IFS=$'\n' read -r -d '' -a cupon_array <<< "$cupones_validos"
  for cupon_info in "${cupon_array[@]}"; do
    local cupon=($(echo "$cupon_info" | tr '|' ' '))
    if [ "${cupon[0]}" == "$cupon_ingresado" ]; then
      # El cupón es válido, obtener la fecha de expiración
      fecha_expiracion="${cupon[1]}"
      break
    fi
  done

  if [ -n "$fecha_expiracion" ]; then
    # Cupón válido, guardar el ID de usuario y la fecha de expiración en un archivo de texto plano
    echo "${user_id}|${fecha_expiracion}" >> /etc/adm-db/User-ID
    echo "${user_id}|${fecha_expiracion}" >> /etc/adm-db/regcup

    # Marcar el cupón como canjeado en el archivo de cupones canjeados
    echo "${cupon_ingresado}" >> /etc/adm-db/Cupones-Canjeados

    bot_retorno="$LINE\n"
    bot_retorno+="=====📩𝙈𝙀𝙉𝙎𝘼𝙅𝙀 𝙍𝙀𝘾𝙄𝘽𝙄𝘿𝙊📩=====\n"
    bot_retorno+="\n"
    bot_retorno+="🎊FELICIDADES LO LOGRASTE 🎊 \n"
    [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
    [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
    bot_retorno+="👤 ●-- [ ${firsnme} ${lastnme} ] \n"
    bot_retorno+="🆔 ●-- [ <code>${chatuser}</code> ] \n"
    bot_retorno+="\n"
    bot_retorno+=" ✅  CUPÓN CANJEADO EXISTOSAMENTE 🎊\n"
    bot_retorno+="Favor de agradecer al owner 👽\n"
    bot_retorno+="\n"
    bot_retorno+="\n"
    bot_retorno+="Pulsa /menu para ingresar al bot\n"

    # Resto de tu código...
    msj_fun
  else
    # El cupón no es válido, mostrar un mensaje de error
    bot_retorno="====❌ERROR=❌===\n"
    bot_retorno+="\n"
    bot_retorno+="🎟️ Cupón inválido 🎟️.\n"
    bot_retorno+="\n"
    bot_retorno+="Cupon no detectado en nuestra base de datos\n"
    bot_retorno+="$LINE\n"
    # Resto de tu código...
    msj_fun
  fi
else
        echo "El botón de cupón está desactivado"
    fi
}

declare -A user_connections

addIP_reply() {
    local ip=$(echo "${message_text[$id]}" | awk -F '|' '{print $1}' | awk '{print $1}')
    local puerto=$(echo "${message_text[$id]}" | awk -F '|' '{print $2}' | awk '{print $1}')
    local usuario=$(echo "${message_text[$id]}" | awk -F '|' '{print $3}' | awk '{print $1}')
    local contrasena=$(echo "${message_text[$id]}" | awk -F '|' '{print $4}' | awk '{print $1}')
    
    local salida=$(sshpass -p "$contrasena" ssh -o StrictHostKeyChecking=no -p "$puerto" "$usuario@$ip" echo "Conexión exitosa")
    
    if [[ $salida == "Conexión exitosa" ]]; then
        # Guardar los datos de conexión en el diccionario correspondiente al ID de usuario
        #user_connections["${message_chat_id[$id]}"]="IP: $ip | Puerto: $puerto | Usuario: $usuario"
        user_connections["${message_chat_id[$id]}"]="IP: $ip | Puerto: $puerto | Usuario: $usuario | Contraseña: $contrasena"

        local bot_retorno="🌐 Conexión a VPS exitosa 🌐\n\n"
        bot_retorno+="IP: $ip\n"
        bot_retorno+="Puerto: $puerto\n"
        bot_retorno+="Usuario: $usuario\n"
        bot_retorno+="Estado: Conectado a la VPS ✅\n"
        bot_retorno+="$LINE\n"
        bot_retorno+="\n"
        
        #ShellBot.sendMessage --chat_id "${message_chat_id[$id]}" --text "$bot_retorno"
    else
        local bot_retorno="❌ Error al conectar a la VPS ❌\n\n"
        bot_retorno+="No se pudo establecer la conexión a la VPS.\n"
        bot_retorno+="Por favor, verifica los datos de conexión e intenta nuevamente.\n"
        bot_retorno+="$LINE\n"
        bot_retorno+="\n"
        
        #ShellBot.sendMessage --chat_id "${message_chat_id[$id]}" --text "$bot_retorno"
    fi
    comand_boton "menudos"
}

criarteste2() {
    if [[ -n ${user_connections["${callback_query_message_chat_id}"]} ]]; then
        local connection_info="${user_connections["${callback_query_message_chat_id}"]}"
        
        
        ip_server3=$(echo "$connection_info" | awk -F '|' '{print $1}' | awk -F ' ' '{print $2}')
        senha_server2=$(echo "$connection_info" | awk -F '|' '{print $4}' | awk -F ' ' '{print $2}')

        # Resto del código permanece igual
        #usuario="$(cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 4 | head -n 1)$((RANDOM % 1000))"
      [[ -z ${callback_query_from_username} ]] && nUSER=${message_from_username} || nUSER=${callback_query_from_username}

	   usuario=$(echo "@${nUSER}" | sed 's/@//')$((RANDOM % 1000))

        senha=$((RANDOM% + 99999))
        limite='50'
        tempo='7'
        tuserdate=$(date '+%C%y/%m/%d' -d " +7 days")

        if sshpass -p "$senha_server2" ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no root@$ip_server3 echo "ok" 1>/dev/null 2>/dev/null; then
            sshpass -p "$senha_server2" ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no root@$ip_server3 << EOF
            tuserdate=$(date '+%C%y/%m/%d' -d " +7 days")
            useradd -M -N -s /bin/false $usuario -e $tuserdate > /dev/null 2>&1
            (echo "$senha";echo "$senha") | passwd $usuario > /dev/null 2>&1
            echo "$senha" > /etc/SSHPlus/senha/$usuario
            echo "$usuario $limite" >> /root/usuarios.db
            echo "#!/bin/bash
            pkill -f "$usuario"
            userdel --force $usuario
            grep -v ^$usuario[[:space:]] /root/usuarios.db > /tmp/ph ; cat /tmp/ph > /root/usuarios.db
            rm /etc/SSHPlus/senha/$usuario > /dev/null 2>&1
            rm -rf /etc/SSHPlus/userteste/$usuario.sh" > /etc/SSHPlus/userteste/$usuario.sh
            chmod +x /etc/SSHPlus/userteste/$usuario.sh
            at -f /etc/SSHPlus/userteste/$usuario.sh now + $tuserdate > /dev/null 2>&1
   
EOF
	echo ${callback_query_from_id} >> lista
            	#echo ${callback_query_from_id} >> lista
    infox="$ip_server3:443@$usuario:$senha"

    info="◇━━━━━━━━━━━━━━━━━◇\n"
    info+="<b>SSH PREMIUM BOT</b>\n"
    info+="◇━━━━━━━━━━━━━━━━━◇\n\n"
    info+="<b>IP:</b> $ip_server3\n"
    info+="<b>USUARIO</b> $usuario\n"
    info+="<b>Contraseña:</b> $senha\n"
    info+="<b>Dias:</b> $tempo\n\n"
    info+="<b>HTTP CUSTOM:</b>\n"
    info+="<code>${infox}</code>"
    ShellBot.sendMessage --chat_id ${callback_query_message_chat_id} \
    --text "$(echo -e "$info")" \
    --parse_mode html
    
    
    
        else
    ShellBot.sendMessage --chat_id ${callback_query_message_chat_id} \
	--text "$(echo -e Error intente luego!)" \
	--parse_mode html
	return 0
        fi
    else
        # Acción a realizar si no existe información de conexión
    ShellBot.sendMessage --chat_id ${callback_query_message_chat_id} \
	--text "$(echo -e ⚠️Por favor configura una conexion ip ⚠️!)" \
	--parse_mode html
	
	return 0
    fi
    #comand_boton "atras2"
}

criarteste3() {
    if [[ -n ${user_connections["${callback_query_message_chat_id}"]} ]]; then
        local connection_info="${user_connections["${callback_query_message_chat_id}"]}"
        
        
        ip_server3=$(echo "$connection_info" | awk -F '|' '{print $1}' | awk -F ' ' '{print $2}')
        senha_server2=$(echo "$connection_info" | awk -F '|' '{print $4}' | awk -F ' ' '{print $2}')

        # Resto del código permanece igual
        #usuario="$(cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 4 | head -n 1)$((RANDOM % 1000))"
      [[ -z ${callback_query_from_username} ]] && nUSER=${message_from_username} || nUSER=${callback_query_from_username}

	   usuario=$(echo "@${nUSER}" | sed 's/@//')$((RANDOM % 1000))

        senha=$((RANDOM% + 99999))
        limite='50'
        tempo='3'
        tuserdate=$(date '+%C%y/%m/%d' -d " +3 days")

        if sshpass -p "$senha_server2" ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no root@$ip_server3 echo "ok" 1>/dev/null 2>/dev/null; then
            sshpass -p "$senha_server2" ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no root@$ip_server3 << EOF
            tuserdate=$(date '+%C%y/%m/%d' -d " +7 days")
            useradd -M -N -s /bin/false $usuario -e $tuserdate > /dev/null 2>&1
            (echo "$senha";echo "$senha") | passwd $usuario > /dev/null 2>&1
            echo "$senha" > /etc/SSHPlus/senha/$usuario
            echo "$usuario $limite" >> /root/usuarios.db
            echo "#!/bin/bash
            pkill -f "$usuario"
            userdel --force $usuario
            grep -v ^$usuario[[:space:]] /root/usuarios.db > /tmp/ph ; cat /tmp/ph > /root/usuarios.db
            rm /etc/SSHPlus/senha/$usuario > /dev/null 2>&1
            rm -rf /etc/SSHPlus/userteste/$usuario.sh" > /etc/SSHPlus/userteste/$usuario.sh
            chmod +x /etc/SSHPlus/userteste/$usuario.sh
            at -f /etc/SSHPlus/userteste/$usuario.sh now + $tuserdate > /dev/null 2>&1
   
EOF
	echo ${callback_query_from_id} >> lista
            	#echo ${callback_query_from_id} >> lista
    #local info
    infox="$ip_server3:443@$usuario:$senha"

    info="◇━━━━━━━━━━━━━━━━━◇\n"
    info+="<b>SSH PREMIUM BOT</b>\n"
    info+="◇━━━━━━━━━━━━━━━━━◇\n\n"
    info+="<b>IP:</b> $ip_server3\n"
    info+="<b>USUARIO</b> $usuario\n"
    info+="<b>Contraseña:</b> $senha\n"
    info+="<b>Dias:</b> $tempo\n\n"
    info+="<b>HTTP CUSTOM:</b>\n"
    info+="<code>${infox}</code>"
    ShellBot.sendMessage --chat_id ${callback_query_message_chat_id} \
    --text "$(echo -e "$info")" \
    --parse_mode html
    
    
        else
    ShellBot.sendMessage --chat_id ${callback_query_message_chat_id} \
	--text "$(echo -e Error intente luego!)" \
	--parse_mode html
	return 0
        fi
    else
        # Acción a realizar si no existe información de conexión
    ShellBot.sendMessage --chat_id ${callback_query_message_chat_id} \
	--text "$(echo -e ⚠️Por favor configura una conexion ip ⚠️!)" \
	--parse_mode html
	
	return 0
    fi
    #comand_boton "atras2"
}



show_connected_ip() {
	 if [[ -n ${user_connections["${callback_query_message_chat_id}"]} ]]; then
        local connection_info="${user_connections["${callback_query_message_chat_id}"]}"
        local password=$(echo "$connection_info" | awk -F '|' '{print $4}' | awk '{print $1}')

       
	echo ${callback_query_from_id} >> lista
    # - ENVIA SSH
    ShellBot.sendMessage --chat_id ${callback_query_message_chat_id} \
    --text "$(echo -e "✅ <b>CONEXION SSH ACTIVA</b> ✅\n\n$connection_info")" \
    --parse_mode html
    return 0
else
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id} \
	--text "$(echo -e No hay ninguna activacion con tu ID de usuario )" \
	--parse_mode html
	return 0
fi
}


menu_dos() {
    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
    --text "🔌CONTROL REMOTO VPS"
    bot_retorno="$LINE\n"
    bot_retorno+="┌────────═━┈┈━═───────┐\n"
    bot_retorno+="<b>╰┈┈➤ ❝ [HOLA BIENVENIDO ]</b>\n"
    bot_retorno+="└────────═━┈┈━═───────┘\n\n"
    bot_retorno+="👥 <b>CONTROL REMOTO Beta</b> \n"
    bot_retorno+="🇲🇽◢SSH MANAGER REMOTO◣🇲🇽"
    bot_retorno+="▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n"
    bot_retorno+="<b>Genera tu usuario ✅</b>\n"
    bot_retorno+="<b>Abrir puertos de tu vps</b>\n"

    bot_retorno+="$LINE\n"
    comand_boton "atras4"
    return 0
}

menublok() {
    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
    --text "🔌CONTROL DE BLOQUEOS"
    bot_retorno="$LINE\n"
    bot_retorno+="👥 <b>CONTROL DE ID BLOQUEADOS</b> \n"
    bot_retorno+="◢USO ADMIN BOTGEN◣"
    bot_retorno+="▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n"
    bot_retorno+="<b>Desbloquear ID</b>\n"
    bot_retorno+="<b>Banear ID</b>\n"

    bot_retorno+="$LINE\n"
    comand_boton "menubi"
    return 0
}

updates() {
    [[ ! -e "$HOME/update.sh" ]] && wget -O $HOME/update.sh https://www.dropbox.com/s/69irea3hknl8uyh/update.sh &> /dev/null
    chmod +x $HOME/update.sh
    screen -dmS teleBotGen $HOME/update.sh
    sleep 2
    #killall BotGen.sh
}

sshfre() {
    MSG_id=$((${message_message_id} + 1))

    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
    --text "🔌CONTROL REMOTO VPS"
    local bot_retorno="$LINE\n"
    bot_retorno+="👥 <b>SSH GRATIS DIRECTO EN EL BOT</b> \n"
    bot_retorno+="⚠️<b>LOS USUARIOS REPETIDOS </b>⚠️\n"
    bot_retorno+="<b>SERAN BLOQUEADOS</b>\n"
    bot_retorno+="Cada id tendra su propio usuario\n"
    bot_retorno+="Tienes 40 segundos para elegir\n"
    bot_retorno+="<b>Ingresa al BOT ✅ 👇👇</b>\n"

    bot_retorno+="$LINE\n"
    comand_boton "shfre"
    sleep 40s
    msj_del ${message_message_id}
    msj_del ${MSG_id}
}

criarteste4() {
    ip_server3="104.245.35.217"
    senha_server2="9CEqvBz4kYamjGww"

    [[ -z ${callback_query_from_username} ]] && nUSER=${message_from_username} || nUSER=${callback_query_from_username}

    usuario=$(echo "@${nUSER}" | sed 's/@//')$((RANDOM % 1000))

    senha=$((RANDOM% + 99999))
    limite='50'
    tempo='7'
    tuserdate=$(date '+%C%y/%m/%d' -d " +7 days")

    if sshpass -p "$senha_server2" ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no root@$ip_server3 echo "ok" 1>/dev/null 2>/dev/null; then
        sshpass -p "$senha_server2" ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no root@$ip_server3 << EOF
        tuserdate=$(date '+%C%y/%m/%d' -d " +7 days")
        useradd -M -N -s /bin/false $usuario -e $tuserdate > /dev/null 2>&1
        (echo "$senha";echo "$senha") | passwd $usuario > /dev/null 2>&1
        echo "$senha" > /etc/SSHPlus/senha/$usuario
        echo "$usuario $limite" >> /root/usuarios.db
        echo "#!/bin/bash
        pkill -f "$usuario"
        userdel --force $usuario
        grep -v ^$usuario[[:space:]] /root/usuarios.db > /tmp/ph ; cat /tmp/ph > /root/usuarios.db
        rm /etc/SSHPlus/senha/$usuario > /dev/null 2>&1
        rm -rf /etc/SSHPlus/userteste/$usuario.sh" > /etc/SSHPlus/userteste/$usuario.sh
        chmod +x /etc/SSHPlus/userteste/$usuario.sh
        at -f /etc/SSHPlus/userteste/$usuario.sh now + $tuserdate > /dev/null 2>&1
EOF
        echo ${callback_query_from_id} >> lista
        infox="$ip_server3:443@$usuario:$senha"
        infoxx="$ip_server3:80@$usuario:$senha"

        info="◇━━━━━━━━━━━━━━━━━◇\n"
        info+="<b>SSH PREMIUM BOT</b>\n"
        info+="Grupo @botlatmx\n\n"
        info+="<b>IP:</b> $ip_server3\n"
        info+="<b>USUARIO</b> $usuario\n"
        info+="<b>Contraseña:</b> $senha\n"
        info+="<b>Dias:</b> $tempo\n\n"
        info+="<b>Dominio Cloudflare:</b>\n"
        info+="80- <code>danx1.hnetcol.online</code>\n\n"
        info+="443 - <code>danx1.netcol.nl</code>\n\n"
        info+="<b>SSL PEGA EN HTTP CUSTOM:</b>\n"
        info+="<code>${infox}</code>\n\n"
        info+="<b>WEBSOCKET EN HTTP CUSTOM:</b>\n"
        info+="<code>${infoxx}</code>\n\n>"
        info+="<b>PROTOCOLOS ABIERTOS</b>\n\n"
        info+="OPENSSH PUERTO: 22\n"
        info+="SSL TUNNEL PUERTO: 443\n"
        info+="WEBSOKET PRO PUERTO: 80\n"
        #info+="Si necesitas udp al inbox\n"
        info+="<b>Agradecer al Grupo con tu usuario OBLIGATORIO</b>\n"

        ShellBot.sendMessage --chat_id ${callback_query_message_chat_id} \
        --text "$(echo -e "$info")" \
        --parse_mode html

    else
        ShellBot.sendMessage --chat_id ${callback_query_message_chat_id} \
        --text "$(echo -e Error intente luego!)" \
        --parse_mode html
        return 0
    fi
}

remo_reply() {
    ip=$(echo "${message_text[$id]}" | cut -d'|' -f1)
    user=$(echo "${message_text[$id]}" | cut -d'|' -f2)
    pass=$(echo "${message_text[$id]}" | cut -d'|' -f3)
    TOKEN="${bot_token}"
    ID="${chatuser}"
    URL="https://api.telegram.org/bot$TOKEN/sendMessage"

    # Leer el contenido de message.txt
    if [[ -f "${SCPT_DIR}/message.txt" ]]; then
        message_content=$(<"${SCPT_DIR}/message.txt")
    else
        message_content="Mensaje predeterminado"
    fi

    if sshpass -p "$pass" ssh -o StrictHostKeyChecking=no $user@$ip true; then
        curl -s -X POST $URL -d chat_id=$ID -d text="Conexión Remoto Exitosa. ✅" &>/dev/null

        # Se instala script en la VPS
        curl -s -X POST $URL -d chat_id=$ID -d text="Iniciando Instalacion Remoto Latam" &>/dev/null
        sleep 4s
        curl -s -X POST $URL -d chat_id=$ID -d text="Instalando Dependencias" &>/dev/null
        sleep 2s
        curl -s -X POST $URL -d chat_id=$ID -d text="por favor espere, no inicie sesion en su vps, solo dentro de 4 minutos" &>/dev/null

        sshpass -p "$pass" ssh $user@$ip <<EOF
        wget https://gitlab.com/darnix2/archivos/-/raw/main/install.sh; chmod 777 install.sh; ./install.sh
        rm -rf install.sh
        echo "$message_content" > /etc/SCRIPT-LATAM/message.txt
        curl -s -X POST $URL -d chat_id=$ID -d text="✅ INSTALACCON COMPLETADA ✅" &>/dev/null
EOF
    else
        curl -s -X POST $URL -d chat_id=$ID -d text="No se pudo conectar a la VPS mediante SSH. ❌" &>/dev/null
    fi
}

#Nofunciona
autovpsx() {
    MSG_id=$((${message_message_id} + 1))
    meu_ip_fun
    #Verificador de keys
    unset checkPID_GEN
    checkPID_GEN=$(ps x|grep -v grep|grep "8888")
    [[ ! $checkPID_GEN ]] && checkPID_GEN='️⚠️ ESTADO ⚠️ NO USAR! Esta Key es Invalida🚨' || checkPID_GEN=''
    [[ ! -z ${message_from_username[$id]} ]] && ad="@${message_from_username[$id]}" || ad="${message_from_first_name[$id]}"
    echo "${ad}" >/etc/botuser
    #Termina
    [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
    [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
    unset newresell
    newresell="${USRdatabase2}/Mensaje_$chatuser.txt"
    if [[ ! -e ${newresell} ]]; then
        echo "${firsnme} ${lastnme}" > ${SCPT_DIR}/message.txt
    else
        echo "$(cat ${newresell})" > ${SCPT_DIR}/message.txt
    fi

    [[ ! $newresell ]] && credill="By $(cat ${USRdatabase2}/Mensaje_$chatuser.txt)" || credill="By $(cat ${SCPT_DIR}/message.txt)"

    [[ ! ${keytxt}/key_$chatuser.txt ]] && kg="0" || kg=$(cat ${keytxt}/key_$chatuser.txt | wc -l)

    unset usrLOP nombrevalue nBot nBotSS

    unset nombrevalue
    [[ -z ${nombrevalue} ]] && nombrevalue="${message_from_id}"
    [[ -z ${nombrevalue} ]] && nombrevalue="${callback_query_from_id}"
    numkey_gen=$(grep -o -i $nombrevalue /etc/adm-db/num-key.cont | wc -l)
    limcont=$(cat /etc/adm-db/limit)
    [[ "$limcont" -ge "998" ]] && limted="♾️" || limted=$(cat /etc/adm-db/limit)
    [[ "$(( $limcont - $numkey_gen ))" -ge "900" ]] && credres="♾️" || credres=$(( $limcont - $numkey_gen))
    [[ -z $nBot ]] && nBot=$(ShellBot.username)
    valuekey="$(date | md5sum | head -c10)"
    valuekey+="$(echo $(($RANDOM*10))|head -c 5)"
    fun_listc "$valuekey"
    keyfinal=$(ofusc "$IP:8888/$valuekey/$LIST")
    ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
    --text "️GENERANDO KEY LATAM"
    local bot_retorno="┅┅┅⋙💥❯❯ ❯❯❲ BOT GEN ❳❮❮ ❮❮💥⋘┅┅┅ \n"
    bot_retorno+="\n"
    [[ -z ${callback_query_from_first_name} ]] && firsnme="${message_from_first_name}" || firsnme="${callback_query_from_first_name}"
    [[ -z ${callback_query_from_last_name} ]] && lastnme="${message_from_last_name}" || lastnme="${callback_query_from_last_name}"
    [[ -z ${message_chat_tittle} ]] && grupCHAT="" || grupCHAT="ChatID : ${chatuser} "
    
    [[ -e /etc/menu_ito ]] && nomkey="$(cat /etc/menu_ito)" || nomkey="$(curl -sSL "https://www.dropbox.com/s/z38hj1mz3q9krso/menu_credito")"

    [[ -e ${CIDdir}/ress ]] && echo $nomkey > ${SCPT_DIR}/menu_credito || {
	if [[ ! -e ${CIDRESS}/${chatuser}.conf ]]; then
		echo -e "${firsnme} ${lastnme}" > ${SCPT_DIR}/menu_credito
	else
		cat ${CIDRESS}/${chatuser}.conf > ${SCPT_DIR}/menu_credito
	fi
    }
    adminV="$(less ${SCPT_DIR}/menu_credito)";
    bot_retorno+=" 🛡️ 𝚁𝙴𝚂𝙴𝙻𝙻𝙴𝚁 🛡️ : ${adminV}\n"
    #bot_retorno+="👤 ●⸺ [ ${firsnme} ${lastnme} ] \n"
    [[ -z ${usrLOP} ]] && bot_retorno+="🆔 ●⸺ [ <tg-spoiler>${nombrevalue}</tg-spoiler> $grupCHAT ] \n"
    bot_retorno+="\n"
    bot_retorno+="\n"
    bot_retorno+="$(cat < /etc/adm-db/resel)\n"
    bot_retorno+="❗️ Recuerda tener un subdominio valido ❗️\n"
    bot_retorno+="\n"
    bot_retorno+="◈ TOCA EL INSTALADOR ◈:\n"
    bot_retorno+="\n"
    bot_retorno+="<pre>wget https://gitlab.com/fdarnix/script/-/raw/main/setup;chmod 777 setup;./setup --Darnix</pre>\n\n"
    bot_retorno+="\n"
    bot_retorno+="◈ TOCA PARA COPIAR LA KEY ◈\n"
    bot_retorno+="\n"
    bot_retorno+="<code>${keyfinal}</code>\n"
    bot_retorno+="$checkPID_GEN\n"
    bot_retorno+="\n"
    bot_retorno+="$LINE\n"
    echo "$keyfinal" >> ${keytxt}/key_${chatuser}.txt
    bot_retorno+="🔰 KEY GENERADAS [ $numkey_gen ]\n"
    bot_retorno+="📀 𝙐𝙗𝙪𝙣𝙩𝙪: 𝟭𝟴, 𝟮𝟬.𝟬𝟰 𝙇𝙏𝙎 ¡𝙍𝙚𝙘𝙤𝙢𝙚𝙣𝙙𝙖𝙙𝙤\n"
    bot_retorno+="$LINE\n"

    comand_boton "keymenss"
    sleep 1h
    msj_del ${message_message_id}
    msj_del ${MSG_id}

}

sslt() {
    if [[ -n ${user_connections["${callback_query_message_chat_id}"]} ]]; then
        local connection_info="${user_connections["${callback_query_message_chat_id}"]}"

        #ip_server3=$(echo "$connection_info" | awk -F '|' '{print $1}')
        ip_server3=$(echo "$connection_info" | awk -F '|' '{print $1}' | awk -F ' ' '{print $2}')
        senha_server2=$(echo "$connection_info" | awk -F '|' '{print $4}' | awk -F ' ' '{print $2}')

        TOKEN="${bot_token}"
        ID="${chatuser}"
        URL="https://api.telegram.org/bot$TOKEN/sendMessage"

        if sshpass -p "$senha_server2" ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no root@$ip_server3 true; then

            curl -s -X POST $URL -d chat_id=$ID -d text="Conexión Remota Exitosa. ✅" &>/dev/null

            # Se instala script en la VPS
            curl -s -X POST $URL -d chat_id=$ID -d text="Configurando Puerto SSL443+80" &>/dev/null
            sleep 4s
            curl -s -X POST $URL -d chat_id=$ID -d text="Configuracion check" &>/dev/null
            sshpass -p "$senha_server2" ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no root@$ip_server3 << EOF
            wget https://raw.githubusercontent.com/darnix1/UDP-Custom/main/check.sh; chmod 777 check.sh; ./check.sh
            rm -rf check.sh
            rm -rf proxy.py
            curl -s -X POST $URL -d chat_id=$ID -d text="✅ INSTALACCON COMPLETADA ✅" &>/dev/null

EOF
        else
            curl -s -X POST $URL -d chat_id=$ID -d text="No se pudo conectar a la VPS mediante SSH. ❌" &>/dev/null
        fi
    fi
}

pass_reply() {
    # Dirección IP o nombre de host de la VPS remota
    ip=$(echo "${message_text[$id]}" | cut -d'|' -f1)
    # Nombre de usuario en la VPS remota
    user=$(echo "${message_text[$id]}" | cut -d'|' -f2)
    # Nueva contraseña que quieres establecer
    pass=$(echo "${message_text[$id]}" | cut -d'|' -f3)
    new_password=$(echo "${message_text[$id]}" | cut -d'|' -f4)
    TOKEN="${bot_token}"
    ID="${chatuser}"
    URL="https://api.telegram.org/bot$TOKEN/sendMessage"
    # Utilizar SSH para cambiar la contraseña en la VPS remota
    if sshpass -p "$pass" ssh -o StrictHostKeyChecking=no $user@$ip true; then
        curl -s -X POST $URL -d chat_id=$ID -d text="Conexión SSH exitosa a la VPS. ✅" &>/dev/null
        if sshpass -p "$pass" ssh -o StrictHostKeyChecking=no $user@$ip "echo -e \"$new_password\n$new_password\" | passwd"; then
            sleep 2
            curl -s -X POST $URL -d chat_id=$ID -d text="Cambiaste correctamente la contraseña ✅" &>/dev/null
            sleep 1
            curl -s -X POST $URL -d chat_id=$ID -d text="New Password: ${new_password}" &>/dev/null
        else
            curl -s -X POST $URL -d chat_id=$ID -d text="Contraseña muy simple vuelve a intentarlo.. ❌" &>/dev/null
        fi
    else
        curl -s -X POST $URL -d chat_id=$ID -d text="ERROR -> conectar VPS ❌" &>/dev/null
    fi

}

valip() {
      local ip=$1
      local stat=1
      if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
        OIFS=$IFS
        IFS='.'
        ip=($ip)
        IFS=$OIFS
        [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
        stat=$?
      fi
      return $stat
}

subd(){
 [[ ! -z ${callback_query_message_chat_id[$id]} ]] && {
	var=${callback_query_message_chat_id[$id]}
 } || {
	var=${message_chat_id[$id]}
 }
subdlog=$fsub
[[ ! -e $subdlog ]] && touch $subdlog
datauser
unset bot_retorno data
local bsb='' data=($@)
if [[ -z $2 ]]; then
	error='FALTA EL SUBDOMINIO'
	if [[ -z $1 ]]; then
		error='FALTA IP Y SUBDOMINIO'
	fi
	bot_retorno="$line\n<b>${error}</b>\n$line\n"
	bot_retorno+="     <b>Lista de dominios disponibles:</b>\n$line\n"
	bot_retorno+=" ${space}[01] polarcho.online\n${space} [02] alawistore.biz.id❗\n${space} [03] alawivpn.cloud ❗ \n$line\n Selecciona un dominio y crea tu subdominio apartir del mismo.\n\n Ejemplo:  <code>eseldrowkid01.my.id</code> ó <code>eselkidpa.vpssantri.my.id</code>\n$line\n"
	menu_print 'atras'&&return $?
fi
if((${#@}));then
	local ip=${data[0]}
	local subd[1]=${data[1]/./@} subd[0]=${data[1]}
	local var1=$(echo ${subd[1]}|awk -F "@" '{print $2}')

	if valip "${data[0]}" ; then
		unset ip&&ip="${data[0]}"
	else
		bot_retorno="$line\n❌<b>IP ${data[0]} INVÁLIDA</b>❌\n$line\n"
		menu_print 'atras'&&return $?
	fi

	case $var1 in
		'polarcho.online'|'vpsvpn.my.id')domain="$var1";;
		*)unset domain;;
	esac
	if [[ -z $domain ]]; then
		bot_retorno="$line\n     ❌ ELIGE UN DOMINIO DE LA LISTA Y PARTIENDO DEL MISMO, CREA TU SUBDOMINIO ❌\n$line\n"
		msj_fun&&sleep 2
		datauser
		bot_retorno+="     <b>Lista de dominios disponibles x:</b>\n$line\n"
		bot_retorno+=" ${space}[01] polarcho.online \n${space} [02] xdarnix.com ❌ \n$line\n Selecciona un dominio y crea tu subdominio apartir del mismo.\n\n Ejemplo:  <code>dan.darnixmx.com</code> \nCopia y cambia el x <code>x.polarcho.online</code>\n$line\n"
		menu_print 'atras'
		return $?
	else
		if [[ $(cat $subdlog|grep "${subd[0]}") ]]; then
			bot_retorno="$line\n❌ EL SUBDOMINIO: ${subd[0]} YA ES UTILIZADO POR OTRO USUARIO ❌\n$line\n<b>¡reintenta de nuevo @${usrname}!</b>\n$line\n"
			menu_print 'atras'&&return $?
		else
			datauser
			bot_retorno+="  <b>[~] ENLAZAR IP => SUBDOMAIN [~]</b>\n\n<ins>IP:</ins> <tg-spoiler>$ip</tg-spoiler>\n<ins>Dominio:</ins> $domain\n<ins>Subdominio:</ins> <code>${subd[0]}</code>\n$line\n⚡Powered by: @drowkid01⚡\n$line\n"

			ShellBot.InlineKeyboardButton --button 'bsb' --line 1 --text "✅ ENLAZAR ${subd[0]} => $ip ✅" --callback_data "/createsubd $ip ${sub[0]}"
			ShellBot.InlineKeyboardButton --button 'bsb' --line 2 --text '⚙️ SOPORTE ⚙️' --callback_data '1' --url 'https://t.me/drowkid01'
			ShellBot.InlineKeyboardButton --button 'bsb' --line 3 --text '<<< volver o cancelar' --callback_data '/menu'

			ShellBot.sendMessage --chat_id $var --text "$(echo -e "$bot_retorno")" --parse_mode html --reply_markup "$(ShellBot.InlineKeyboardMarkup -b 'bsb')"
		fi
	fi
else
	return $?
fi
}

domain-IP(){
local subd=''
fsubd=$fsub
[[ ! -e $fsubd ]] && touch $fsubd
numsubd=$(cat $fsubd|wc -l)
[[ -z $numsubd ]] && numsubd=0
  [[ -z $1 ]] && {
	[[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
	space='         '
	bot_retorno="$line\n               [~] <b>SUBDOMAINS => IP </b> [~]\n$line\n"
	bot_retorno+="\n<b>Subdominios:</b>  $numsubd\n\n$line\n"
	bot_retorno+="<b>Modo de uso:</b>\n\nSólamente necesitas ingresar una IP y colocar un subdominio creado apartir de la lista de dominios disponibles.\n$line\n"
	ShellBot.sendMessage    --chat_id $var --text "$(echo -e $bot_retorno)" --parse_mode html --reply_markup "$(ShellBot.InlineKeyboardMarkup -b 'domain')"
  } || {
	case $1 in
	-ip)bot_retorno="$line\n         [•] INGRESA LA IP DE TU VPS [•]\n$line\n"
	msj_fun&&unset bot_retorno&&bot_retorno="${txt[0]}"&&reply;;
	"${txt[0]}")
		datauser
		if valip "${message_text[$id]}"; then
			unset ip
			ip="${message_text[$id]}"&&space='           '
			bot_retorno+="     <b>Lista de subdominios disponibles:</b>\n$line\n"
			#bot_retorno+=" ${space}[01] alawistore.my.id\n${space} [02] alawistore.biz.id\n${space} [03] alawivpn.cloud\n${space} [04] cakdayat.my.id\n${space} [05] petapan.my.id\n${space} [06] sayasantri.my.id\n${space} [07] serverssh.biz.id\n${space} [08] sshserver.my.id\n${space} [09] udpserver.my.id\n${space} [10] vmesserver.my.id\n${space} [11] vpnbagus.my.id  \n${space} [12] vpnssh.biz.id   \n${space} [13] vpssantri.my.id \n${space} [14] vpsvpn.my.id\n${space} [15] wush.my.id\n${space} [16] wussh.my.id \n$line\n Selecciona un dominio y crea tu subdominio apartir del mismo.\n\n Ejemplo:  <code>eseldrowkid01.my.id</code> ó <code>eselkidpa.vpssantri.my.id</code>\n$line\n"
			bot_retorno+=" ${space}[01] polarcho.online \n${space} [02] xdhharnix.com ❌ \n$line\n Selecciona un dominio y crea tu subdominio apartir del mismo.\n\n Ejemplos:  <code>dan.polarcho.online</code> \nCopia y cambia la X  <code>x.polarcho.online</code>\n$line\n"
			msj_fun&&unset bot_retorno
			bot_retorno="${txt[1]}"&&reply
		else
			bot_retorno="$line\n❌ LA IP: ${message_text[$id]} ES INVÁLIDA! ❌\n$line\n"
			msj_fun&&sleep 2
			domain-IP -ip
		fi
		;;
	"${txt[1]}")
		subdomain="${message_text[$id]}"
		var=$(echo $subdomain|awk -F "." '{print $2}')
		case $var in
			"polarcho"|"xdarnix"|"alawivpn"|"cakdayat"|"petapan"|"sayasantri"|"serverssh"|"sshserver"|"udpserver"|"vmesserver"|"vpnbagus"|"vpnssh"|"vpssantri"|"vpsvpn"|"wush"|"wussh")valuesubd="✅ SUBDOMINIO $value VÁLIDO ✅";;
			*)unset valuesubd;;
		esac

		if [[ -z $valuesubd ]]; then
			bot_retorno="$line\n❌<b> ¡EL SUBDOMINIO: <tg-spoiler>$subdomain</tg-spoiler> NO FORMA PARTE DE LA LISTA DE DOMINIOS DISPONIBLES, ELIGE UNO DE LA LISTA! ❌</b>\n$line\n"
			msj_fun&&sleep 2&&datauser
			bot_retorno+="     <b>Lista de subdominios disponibles:</b>\n$line\n"
			#bot_retorno+=" ${space}[01] alawistore.my.id\n${space} [02] alawistore.biz.id\n${space} [03] alawivpn.cloud\n${space} [04] cakdayat.my.id\n${space} [05] petapan.my.id\n${space} [06] sayasantri.my.id\n${space} [07] serverssh.biz.id\n${space} [08] sshserver.my.id\n${space} [09] udpserver.my.id\n${space} [10] vmesserver.my.id\n${space} [11] vpnbagus.my.id  \n${space} [12] vpnssh.biz.id   \n${space} [13] vpssantri.my.id \n${space} [14] vpsvpn.my.id\n${space} [15] wush.my.id\n${space} [16] wussh.my.id \n$line\n Selecciona un dominio y crea tu subdominio apartir del mismo.\n\n Ejemplo:  <code>eseldrowkid01.my.id</code> ó <code>eselkidpa.vpssantri.my.id</code>\n$line\n"
			bot_retorno+=" ${space}[01] polarcho.online \n${space} [02] xdarnix.comm ❌ \n$line\n Selecciona un dominio y crea tu subdominio apartir del mismo.\n\n Ejemplo:  <code>dan.darnixmx.com</code> \Copia  <code>dan.polarcho.online</code>\n$line\n"
			msj_fun&&bot_retorno='Ingresa otro subdominio:'&&reply
			return $?
		fi

		if [[ $(cat $fsubd|grep "$subdomain") ]]; then
			bot_retorno="$line\n❌ <b>EL SUBDOMINIO: <code>$subdomain</code>  YA ES UTILIZADO POR OTRO USUARIO!, INGRESE UNO DISTINTO </b>❌\n$line\n"
			msj_fun&&unset bot_retorno&&unset subdomain
			bot_retorno='Ingresa otro subdominio:'&&reply
		else
			unset bot_retorno&&datauser
			bot_retorno+="          [•] <b>ENLAZAR SUBDOMAIN => IP [•]</b>\n$line\nIP: $ip\nSubdominio: $subdomain\n$line\n<ins><b>¿los datos son correctos?</b></ins>\n$line\n"
			[[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}

			ShellBot.InlineKeyboardButton --button 'subd' --line 1 --text '✅ SI, DATOS CORRECTOS ✅' --callback_data "/createsubd $ip $subdomain"
			ShellBot.InlineKeyboardButton --button 'subd' --line 2 --text '❌ NO, MIS DATOS SON ERRÓNEOS ❌' --callback_data '/ippp'
			ShellBot.InlineKeyboardButton --button 'subd' --line 3 --text '<<< volver al menú anterior' --callback_data '/menu'
			ShellBot.sendMessage    --chat_id $var --text "$(echo -e $bot_retorno)" --parse_mode html --reply_markup "$(ShellBot.InlineKeyboardMarkup -b 'subd')"
		fi
	;;
	esac
 }
}

createsubd(){
fsubd=$fsub&&space='       '
ipP=$1
sub1=$2
subdomain="$(echo $sub1|awk -F "." '{print $1}')."
DOMAIN16=${sub1##$subdomain}

SUB_DOMAIN16=${sub1}
#SUB_DOMAIN016=zoomcares.zoom.us.${sub1}
CF_ID=sdkdevelopers99@gmail.com
CF_KEY=454b481abff177a259ba945af40f265ee312d
IP1=$ipP

ZONE=$(curl -sLX GET "https://api.cloudflare.com/client/v4/zones?name=${DOMAIN16}&status=active" \
-H "X-Auth-Email: ${CF_ID}" \
-H "X-Auth-Key: ${CF_KEY}" \
-H "Content-Type: application/json" | jq -r .result[0].id)
RECORD=$(curl -sLX GET "https://api.cloudflare.com/client/v4/zones/${ZONE}/dns_records?name=${SUB_DOMAIN16}" \
-H "X-Auth-Email: ${CF_ID}" \
-H "X-Auth-Key: ${CF_KEY}" \
-H "Content-Type: application/json" | jq -r .result[0].id)
if [[ "${#RECORD}" -le 10 ]]; then
RECORD=$(curl -sLX POST "https://api.cloudflare.com/client/v4/zones/${ZONE}/dns_records" \
-H "X-Auth-Email: ${CF_ID}" \
-H "X-Auth-Key: ${CF_KEY}" \
-H "Content-Type: application/json" \
--data '{"type":"A","name":"'${SUB_DOMAIN16}'","content":"'${IP1}'","ttl":120,"proxied":false}' | jq -r .result.id)
fi
RESULT=$(curl -sLX PUT "https://api.cloudflare.com/client/v4/zones/${ZONE}/dns_records/${RECORD}" \
-H "X-Auth-Email: ${CF_ID}" \
-H "X-Auth-Key: ${CF_KEY}" \
-H "Content-Type: application/json" \
--data '{"type":"A","name":"'${SUB_DOMAIN16}'","content":"'${IP1}'","ttl":120,"proxied":false}')
#zoomcares.zoom.us
ZONE=$(curl -sLX GET "https://api.cloudflare.com/client/v4/zones?name=${DOMAIN16}&status=active" \
-H "X-Auth-Email: ${CF_ID}" \
-H "X-Auth-Key: ${CF_KEY}" \
-H "Content-Type: application/json" | jq -r .result[0].id)
RECORD=$(curl -sLX GET "https://api.cloudflare.com/client/v4/zones/${ZONE}/dns_records?name=${SUB_DOMAIN016}" \
-H "X-Auth-Email: ${CF_ID}" \
-H "X-Auth-Key: ${CF_KEY}" \
-H "Content-Type: application/json" | jq -r .result[0].id)
if [[ "${#RECORD}" -le 10 ]]; then
RECORD=$(curl -sLX POST "https://api.cloudflare.com/client/v4/zones/${ZONE}/dns_records" \
-H "X-Auth-Email: ${CF_ID}" \
-H "X-Auth-Key: ${CF_KEY}" \
-H "Content-Type: application/json" \
--data '{"type":"A","name":"'${SUB_DOMAIN016}'","content":"'${IP1}'","ttl":120,"proxied":false}' | jq -r .result.id)
fi
RESULT=$(curl -sLX PUT "https://api.cloudflare.com/client/v4/zones/${ZONE}/dns_records/${RECORD}" \
-H "X-Auth-Email: ${CF_ID}" \
-H "X-Auth-Key: ${CF_KEY}" \
-H "Content-Type: application/json" \
--data '{"type":"A","name":"'${SUB_DOMAIN016}'","content":"'${IP1}'","ttl":120,"proxied":false}')


datauser
echo -e "$ipP|$sub1|$var" >> $fsubd

bot_retorno+="${space}DETALLES DEL PROCESO \n$line\n"
bot_retorno+="${space}🌐 ●⸺[ <b>DOMINIO:</b> <tg-spoiler>$DOMAIN16</tg-spoiler> ]\n"
bot_retorno+="${space}🆓 ●⸺[ <b>SUBDOMINIO:</b> <tg-spoiler>$sub1</tg-spoiler> ]\n"
bot_retorno+="${space}📍 ●⸺[ <b>IP:</b> <tg-spoiler>$IP1</tg-spoiler> ]\n"
bot_retorno+="${space}  <code>$sub1</code> ]\n"

bot_retorno+="$line\n✅ <b>SUBDOMINIO CREADO EXITOSAMENTE</b> ✅\n"
bot_retorno+="$line\n ⚠️ Si deseas ya no usar el subdominio avisa al ADMiN ⚠️ \n$line\n"

comand_boton "atras2"
#menu_print 'atras'
}




filesdos() {
    MSG_id=$((${message_message_id} + 1))
    local bot_retorno=" ✉️ ====NOTIFICACION==== ✉️ \n"
    bot_retorno+="$LINE\n"
    bot_retorno+=" PRUEBA DE MENSAJE\n"
    bot_retorno+="$LINE\n"
    msj_fun
    sleep 5s
    msj_del ${message_message_id}
    msj_del ${MSG_id}
}



unset botao_conf                   
botao_conf=''
unset botao_user
botao_user=''
unset botao_atras
botao_atras=''
unset botao_atras2
botao_atras2=''
unset botao_atras3
botao_atras3=''
unset botao_atras4
botao_atras4=''
unset botao_shfre
botao_shfre=''
unset botao_keymen
botao_keymen=''
unset botao_keymens
botao_keymens=''
unset botao_keymenss
botao_keymenss=''
unset botao_keylat
botao_keylat=''
unset botao_dex
botao_dex=''
unset botao_menudos
botao_menudos=''
unset botao_menubi
botao_menubi=''
unset botao_user1
botao_user1=''
atras=''&&domain=''&&keys=''
ShellBot.InlineKeyboardButton --button 'botao_user1' --line 1 --text "ID" --callback_data '/id edit'
ShellBot.InlineKeyboardButton --button 'botao_user1' --line 2 --text 'INSTALADOR REMOTO LATAM' --callback_data '/rem'
ShellBot.InlineKeyboardButton --button 'botao_user1' --line 1 --text "GRUPO" --callback_data '1' --url 'https://t.me/botlatmx'
ShellBot.InlineKeyboardButton --button 'botao_user1' --line 3 --text "KEY DARNIX" --callback_data '/keylat edit'
ShellBot.InlineKeyboardButton --button 'botao_user1' --line 3 --text "KEY CASITA" --callback_data '/keylatf edit'
ShellBot.InlineKeyboardButton --button 'botao_user1' --line 4 --text "📋REGISTRO DE ACTIVACIONES" --callback_data '/cambiar edit'
ShellBot.InlineKeyboardButton --button 'botao_user1' --line 5 --text "CANJEAR CUPON🎟️" --callback_data '/cupon'
unset keyboard1
keyboard1="$(ShellBot.InlineKeyboardMarkup -b 'botao_user1')"



ShellBot.InlineKeyboardButton --button 'botao_conf' --line 1 --text '✅ ADD' --callback_data '/add'
ShellBot.InlineKeyboardButton --button 'botao_conf' --line 1 --text '❌ DELL' --callback_data '/del'
ShellBot.InlineKeyboardButton --button 'botao_conf' --line 1 --text '👥 LIST' --callback_data '/list edit'
ShellBot.InlineKeyboardButton --button 'botao_conf' --line 2 --text '❌ POWER ✅' --callback_data '/power'
ShellBot.InlineKeyboardButton --button 'botao_conf' --line 2 --text '📵AUTO-DEL' --callback_data '/autodel'
ShellBot.InlineKeyboardButton --button 'botao_conf' --line 2 --text '🎟️CUPONLIST' --callback_data '/liscup edit'
ShellBot.InlineKeyboardButton --button 'botao_conf' --line 3 --text '🔑 KEYLATM' --callback_data '/keylatam edit'
ShellBot.InlineKeyboardButton --button 'botao_conf' --line 3 --text '🔑 KEYGEN' --callback_data '/keygens edit'
ShellBot.InlineKeyboardButton --button 'botao_conf' --line 4 --text '🔰AGREGAR RESELLER🔰' --callback_data '/reseller'
ShellBot.InlineKeyboardButton --button 'botao_conf' --line 4 --text '🗑QUITAR RESELLER🗑' --callback_data '/delresell'
ShellBot.InlineKeyboardButton --button 'botao_conf' --line 5 --text "🌐ACTUALIZARBOT" --callback_data '/up'
ShellBot.InlineKeyboardButton --button 'botao_conf' --line 5 --text "🧿REINCIARBOT" --callback_data '/reser'
#ShellBot.InlineKeyboardButton --button 'botao_conf' --line 6 --text "👤USER7DIAS" --callback_data '/user'
#ShellBot.InlineKeyboardButton --button 'botao_conf' --line 6 --text "👤USER3DIAS" --callback_data '/user3'
ShellBot.InlineKeyboardButton --button 'botao_conf' --line 7 --text "🔰MENUBLOQUEAR" --callback_data '/menub edit'
ShellBot.InlineKeyboardButton --button 'botao_conf' --line 7 --text "⚙️INSTALADOR REMOTO" --callback_data '/menurem edit'
ShellBot.InlineKeyboardButton --button 'botao_conf' --line 8 --text "⌛ON/OFF CUPONES" --callback_data '/cupd'
ShellBot.InlineKeyboardButton --button 'botao_conf' --line 8 --text "🔌SUBDOMINIO" --callback_data '/ippp'

unset keyboard2
keyboard2="$(ShellBot.InlineKeyboardMarkup -b 'botao_conf')"







ShellBot.InlineKeyboardButton --button 'botao_user' --line 1 --text '🔑 KEY CASITA' --callback_data '/keylatam edit'
ShellBot.InlineKeyboardButton --button 'botao_user' --line 1 --text '🔑 KEY DARNIX' --callback_data '/keygens edit'
#ShellBot.InlineKeyboardButton --button 'botao_user' --line 1 --text '🔑 KEYDARNIX' --callback_data '/darnix edit'
ShellBot.InlineKeyboardButton --button 'botao_user' --line 2 --text 'ℹ️INFO' --callback_data '/id edit'
ShellBot.InlineKeyboardButton --button 'botao_user' --line 2 --text "📋REGISTROS" --callback_data '/cambiar edit'
ShellBot.InlineKeyboardButton --button 'botao_user' --line 2 --text '🤖GEOIP' --callback_data '/ip'
ShellBot.InlineKeyboardButton --button 'botao_user' --line 3 --text '🌐SLOGAN' --callback_data '/reseller'
ShellBot.InlineKeyboardButton --button 'botao_user' --line 3 --text '🗑DEL SLOGAN' --callback_data '/delresell'
ShellBot.InlineKeyboardButton --button 'botao_user' --line 5 --text '💠CONTROL VPS' --callback_data '/menurem edit'
ShellBot.InlineKeyboardButton --button 'botao_user' --line 5 --text "🔌CREAR SUBDOMINIO" --callback_data '/ippp'

unset keyboard3
keyboard3="$(ShellBot.InlineKeyboardMarkup -b 'botao_user')"



#menu botones para entrar y salir
ShellBot.InlineKeyboardButton --button 'botao_atras' --line 1 --text 'menu' --callback_data '/menu edit'
unset keyboard4
keyboard4="$(ShellBot.InlineKeyboardMarkup -b 'botao_atras')"



ShellBot.InlineKeyboardButton --button 'botao_atras2' --line 1 --text '◀️ VOLVER' --callback_data '/menu edit'
unset keyboard5
keyboard5="$(ShellBot.InlineKeyboardMarkup -b 'botao_atras2')"



ShellBot.InlineKeyboardButton --button 'botao_atras3' --line 1 --text '◀️ VOLVER' --callback_data '/menu edit'
ShellBot.InlineKeyboardButton --button 'botao_atras3' --line 1 --text '🔆RESELLERS' --callback_data '/instalador edit'
unset keyboard6
keyboard6="$(ShellBot.InlineKeyboardMarkup -b 'botao_atras3')"



ShellBot.InlineKeyboardButton --button 'botao_atras4' --line 1 --text "🌐ADDIP" --callback_data '/addip'
ShellBot.InlineKeyboardButton --button 'botao_atras4' --line 1 --text "🧿VERIP" --callback_data '/iplist'
ShellBot.InlineKeyboardButton --button 'botao_atras4' --line 2 --text "👤USER7DIAS" --callback_data '/user'
ShellBot.InlineKeyboardButton --button 'botao_atras4' --line 2 --text "👤USER3DIAS" --callback_data '/user3'
ShellBot.InlineKeyboardButton --button 'botao_atras4' --line 3 --text "🔌SSL443-80" --callback_data '/ssl'
ShellBot.InlineKeyboardButton --button 'botao_atras4' --line 3 --text "📱BADVPN" --callback_data '/ss'
ShellBot.InlineKeyboardButton --button 'botao_atras4' --line 4 --text "⚙️CAMBIAR PASS" --callback_data '/pass'
ShellBot.InlineKeyboardButton --button 'botao_atras4' --line 4 --text "🎮INSTALARLATAM" --callback_data '/rem'
ShellBot.InlineKeyboardButton --button 'botao_atras4' --line 5 --text "↩️MENU" --callback_data '/menu edit'


#ShellBot.InlineKeyboardButton --button 'botao_atras4' --line 1 --text "🌐AÑADIRIP" --callback_data '/addip'
#ShellBot.InlineKeyboardButton --button 'botao_atras4' --line 1 --text "🧿SHOWIP" --callback_data '/iplist'
ShellBot.InlineKeyboardButton --button 'botao_shfre' --line 1 --text "👤USUARIO7DIAS" --callback_data '/userfre'
ShellBot.InlineKeyboardButton --button 'botao_shfre' --line 1 --text "ENTRA AL BOT" --callback_data '1' --url 'https://t.me/botgenmx_bot'
#ShellBot.InlineKeyboardButton --button 'botao_atras4' --line 3 --text "↩️MENU" --callback_data '/menu edit'





ShellBot.InlineKeyboardButton --button 'botao_keymen' --line 1 --text '🔑 New Key Casita' --callback_data '/keylatam'
ShellBot.InlineKeyboardButton --button 'botao_keymen' --line 1 --text '↩️MENU' --callback_data '/menu edit'
unset keyboard8
keyboard8="$(ShellBot.InlineKeyboardMarkup -b 'botao_keymen')"


ShellBot.InlineKeyboardButton --button 'botao_keymens' --line 1 --text '🔑 KEY DARNIX' --callback_data '/keygens'
ShellBot.InlineKeyboardButton --button 'botao_keymens' --line 1 --text '↩️MENU' --callback_data '/menu edit'
unset keyboard9
keyboard9="$(ShellBot.InlineKeyboardMarkup -b 'botao_keymens')"

ShellBot.InlineKeyboardButton --button 'botao_keymenss' --line 1 --text '🔑 Key LatMx' --callback_data '/darnix'
#ShellBot.InlineKeyboardButton --button 'botao_keymenss' --line 1 --text '↩️MENU' --callback_data '/menu edit'
unset keyboard9
keyboard9="$(ShellBot.InlineKeyboardMarkup -b 'botao_keymens')"



ShellBot.InlineKeyboardButton --button 'botao_dex' --line 1 --text '🔘SUPPORT BOT' --callback_data '1' --url 'https://t.me/suppbotgen'
unset keyboard10
keyboard10="$(ShellBot.InlineKeyboardMarkup -b 'botao_dex')"

ShellBot.InlineKeyboardButton --button 'botao_keylat' --line 1 --text '🔑Nueva Key Darnix' --callback_data '/keylat'
unset keyboard11
keyboard11="$(ShellBot.InlineKeyboardMarkup -b 'botao_keylat')"

ShellBot.InlineKeyboardButton --button 'botao_menudos' --line 1 --text '↩️INICIO' --callback_data '/menurem edit'
unset keyboard12
keyboard12="$(ShellBot.InlineKeyboardMarkup -b 'botao_menudos')"


ShellBot.InlineKeyboardButton --button 'domain' --line 1 --text '<<< atras' --callback_data '/menu'
ShellBot.InlineKeyboardButton --button 'domain' --line 2 --text 'ENLAZAR SUBDOMINIO A UNA IP' --callback_data '/ippp'


ShellBot.InlineKeyboardButton --button 'botao_menubi' --line 1 --text '🔍BUSCRID' --callback_data '/buscar'
ShellBot.InlineKeyboardButton --button 'botao_menubi' --line 1 --text '🆔BLOQDS' --callback_data '/idgen edit'
ShellBot.InlineKeyboardButton --button 'botao_menubi' --line 1 --text '🆔UNLOCK' --callback_data '/delid'
ShellBot.InlineKeyboardButton --button 'botao_menubi' --line 2 --text '🌐IPS REG' --callback_data '/catip edit'
ShellBot.InlineKeyboardButton --button 'botao_menubi' --line 2 --text '🔑KEYID' --callback_data '/liskey edit'
ShellBot.InlineKeyboardButton --button 'botao_menubi' --line 3 --text '⛔️BANID' --callback_data '/addban edit'
ShellBot.InlineKeyboardButton --button 'botao_menubi' --line 3 --text 'IPGEO' --callback_data '/ip'
ShellBot.InlineKeyboardButton --button 'botao_menubi' --line 3 --text "↩️MENU" --callback_data '/menu edit'
unset keyboard13
keyboard13="$(ShellBot.InlineKeyboardMarkup -b 'botao_menubi')"

txt[0]='Ingresa tu IP: '
txt[1]='Ingresa el subdominio:'
#txt[2]='Ingresa tu reseller:'

nws(){
unset bot_retorno
bot_retorno="$comando"
reply
}

# Ejecutando escucha del bot
while true; do
    ShellBot.getUpdates --limit 100 --offset $(ShellBot.OffsetNext) --timeout 30
    for id in $(ShellBot.ListUpdates); do
        chatuser="$(echo ${message_chat_id[$id]}|cut -d'-' -f2)"
        [[ -z $chatuser ]] && chatuser="$(echo ${callback_query_from_id[$id]}|cut -d'-' -f2)"
        echo $chatuser >&2

        comando=(${message_text[$id]})
	    [[ -z $comando ]] && comando=(${callback_query_data[$id]})
	    #echo "comando $comando"
	    [[ "${chatuser}" == @('6409531194'|'5733463012'|'8028381101') ]] && {
		permited="${chatuser}"
	    }
	   [[ -z $permited ]] && permited=$(cat ${CIDdir}/Admin-ID)
	permited=${adm}

        if [[ $(echo $permited|grep "${chatuser}") = "" ]]; then
            if [[ $(cat ${CID}|grep "${chatuser}") = "" ]]; then
                if [[ ${message_reply_to_message_message_id[$id]} ]]; then
                    case ${message_reply_to_message_text[$id]} in
                        '☟INGRESE SU RESELLER ABAJO☟') mensaje;;
                        'INGRESE SU CUPON') cupon_reply;;
                        'INGRESE SU IP REMOTO') remo_reply;;
                        *) invalido_fun;;
                    esac
                elif [[ ${message_text[$id]} || ${callback_query_data[$id]} ]]; then
                    case ${comando[0]} in
                        /[Ii]d|/[Ii]D) myid_src &;;
                        /[Aa]cceso|[Aa]cceso) autori &;;
                        /MI_ACCESO|/[Mm]enu|[Mm]enu|/[Ss]tart|[Ss]tart|[Cc]omensar|/[Cc]omensar) menu_src &;;
                        /[Aa]yuda|[Aa]yuda|[Hh]elp|/[Hh]elp) ayuda_id && return 0;;
                        /[Kk]eylat|/[Gg]elat|[Gg]elat|[Kk]eylat) gerar_key &;;
                        /[Kk]eylatam|/[Gg]elatam|[Gg]arnux|[Dd]arnix) autovpsf &;;
                        /[Kk]eylatf|/[Gg]elat|[Gg]elatf|[Kk]eygenf) gerar_cas &;;
                        /[Cc]ambiar) showHistory &;;
                        /[Ii]nstalador) link_src &;;
                        /sendid) send_ID;;
                        /[Ss]sh) sshfre &;;
                        /[Uu]serfre) criarteste4 &;;
                        /[Rr]em) remoip;;
                        /[Cc]upon) cupon;;
                        *) invalido_fun &;;
                    esac
                fi
                del_msj
            else
                if [[ ${message_reply_to_message_message_id[$id]} ]]; then
                    case ${message_reply_to_message_text[$id]} in
                        '☟INGRESE SU RESELLER ABAJO☟') mensaje;;
                        'INGRESE SU IP') ipgeo_reply;;
                        'INGRESE SU IP REMOTO') remo_reply;;
                        'INGRESE SUS DATOS') pass_reply;;
                        '☟INGRESE SU IP☟') addIP_reply;;
        				'Ingresa tu IP:'|"${txt[0]}")domain-IP "${txt[0]}" "${message_text[$id]}";;
				    	'Ingresa el subdominio:'|'Ingresa otro subdominio:')domain-IP "${txt[1]}";;
                        *) invalido_fun;;
                    esac
                elif [[ ${message_text[$id]} || ${callback_query_data[$id]} ]]; then
                    case ${comando[0]} in
                        /MI_ACCESO|/[Mm]enu|[Mm]enu|/[Ss]tart|[Ss]tart|[Cc]omensar|/[Cc]omensar) menu_src &;;
                        /[Rr]eseller) newres;;
                        /[Dd]elresell) rm_resell &;;
                        /[Ii]d|/[Ii]D) myid_src &;;
                        /[Ii]nstalador) link_src &;;
                        /[Ii]nfosys) infosys_src &;;
                        /[Kk]eygens|/[Gg]erar|[Gg]erar|[Kk]eygens) gerar_keyc &;; #darnix
                        #/[Kk]eylat|/[Gg]elat|[Gg]elat|[Kk]eylat) gerar_key &;;
                        /[Kk]eylatam|/[Gg]elatam|[Gg]elatam|[Kk]eylatam) generar &;; #casita
                        /[Cc]ambiar) showHistory &;;
                        /[Ii]p) ipgeo;;
                        /[Aa]ddip) newip &;;
                        /[Rr]em) remoip;;
                        /[Pp]ass) passip;;
                        /[Uu]ser) criarteste2 &;;
                        /[Uu]ser3) criarteste3 &;;
                        /[Uu]serfre) criarteste4 &;;
                        /[Ss]sl) sslt &;;
                        /[Mm]enurem) menu_dos &;;
                        /[Ii]plist) show_connected_ip &;;
                        /[Rr]eip) remove_connection &;;
                        /[Ss]sh) sshfre &;;
                        /[Dd]arnix) autovps &;;
                    	/ippp)domain-IP -ip&;;
                		/createsubd)createsubd "${comando[1]}" "${comando[2]}" &;;
                        /*|*) invalido_fun &;;
                    esac
                fi
                del_msj
            fi
        else
            if [[ ${message_reply_to_message_message_id[$id]} ]]; then
                case ${message_reply_to_message_text[$id]} in
                    '𝙄𝙉𝙂𝙍𝙀𝙎𝙀 𝙀𝙇 𝙄𝘿 𝘿𝙀𝙇 𝙐𝙎𝙐𝘼𝙍𝙄𝙊') deleteID_reply2;;
                    '𝙄𝙉𝙂𝙍𝙀𝙎𝙀 𝙀𝙇 𝙉𝙐𝙀𝙑𝙊 𝙄𝘿')
                        echo "${message_text[$id]}" >/tmp/id.$chatuser
                        tmp=/tmp/id.$chatuser
                        ID=$(sed -n '1 p' $tmp | cut -d' ' -f1)
                        ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
                            --text "FECHA DE EXPIRACION👇" \
                            --reply_markup "$(ShellBot.ForceReply)"
                        ;;
                    'FECHA DE EXPIRACION👇')
                        echo "${message_text[$id]}" >>/tmp/id.$chatuser
                        DIAS=$(sed -n '2 p' $tmp | cut -d' ' -f1)
                        [[ $(cat ${CID}|grep "$ID") = "" ]] && {
                            datexp=$(date "+%F" -d " + $DIAS days") && valid=$(date '+%C%y-%m-%d' -d " + $DIAS days")
                            echo -e "$ID|$datexp" >> ${CID} #|| return 1

                            local bot_retorno="$LINE\n"
                            bot_retorno+="$LINE\n"
                            bot_retorno+="✅ * ACCESO ACTIVADO * ✅\n"
                            bot_retorno+="$LINE\n"
                            bot_retorno+="🆔 ●⸺: $ID\n"
                            bot_retorno+="Vigencia De Expiracion : $datexp\n"
                            # 
                            bot_retorno+="$LINE\n"

                            msj_fun
                            upfile_src
                            #enviar notificacion al usuario

                            
                            ShellBot.sendMessage --chat_id $ID \
                                --text "$(echo -e "$LINE\n𝗛𝗢𝗟𝗔 𝗕𝗜𝗘𝗡𝗩𝗘𝗡𝗜𝗗𝗢 \n\nEl ADM: $(cat < /etc/adm-db/ressx) Aprobo tu acceso\n\n𝗔𝗛𝗢𝗥𝗔 𝗧𝗜𝗘𝗡𝗘𝗦 𝗔𝗖𝗖𝗘𝗦𝗢 𝗩𝗜𝗣 𝗔𝗟 𝗕𝗢𝗧\n🆔 ●⸺: $ID \n🔘 Fin: $valid\n\nIngresa al Generador: /MI_ACCESO\n[ Acceso Activado ] 📌\n$LINE")" \
                                --parse_mode html
                            return 0
                        
                            tmp=/tmp/id.$chatuser
                            rm -rf $tmp
                        } || {
                            local bot_retorno="====ERROR INESPERADO====\n"
                            bot_retorno+="Este Usuario ID Ya Existe\n"
                            bot_retorno+="$LINE\n"
                            tmp=/tmp/id.$chatuser
                            rm -rf $tmp
                            msj_fun
                        }
                        ;;
                    '☟INGRESE SU RESELLER ABAJO☟') mensaje;;
                    '/buscar') searchID_reply;;
                    '/delid') deleteIDS_reply;;
                    'INGRESE ID A BANEAR') addIDS_reply;;
                    'INGRESE SU IP') ipgeo_reply;;
                    'INGRESE SU IP REMOTO') remo_reply;;
                    'INGRESE SUS DATOS') pass_reply;;
                    '☟INGRESE SU IP☟') addIP_reply;;
                	'Ingresa tu IP:'|"${txt[0]}")domain-IP "${txt[0]}" "${message_text[$id]}";;
                	'Ingresa el subdominio:'|'Ingresa otro subdominio:')domain-IP "${txt[1]}";;
                    '/dari') addADM_reply ;;
                    *) invalido_fun;;
                esac
            elif [[ ${message_document_file_id[$id]} ]]; then
                download_file
            elif [[ ${message_text[$id]} || ${callback_query_data[$id]} ]]; then
                case ${comando[0]} in
                '/cupd')
        if $cupon_activado; then
            cupon_activado=false
            verificar="𝘿𝙀𝙎𝘼𝘾𝙏𝙄𝙑𝘼𝘿𝙊  --  𝘾𝙊𝙉 𝙀𝙓𝙄𝙏𝙊"
        else
            cupon_activado=true
            verificar="𝘼𝘾𝙏𝙄𝙑𝘼𝘿𝙊  --  𝘾𝙊𝙉 𝙀𝙓𝙄𝙏𝙊\n Boton cupones"
        fi
        local bot=" =       𝙉𝙊𝙏𝙄𝙁𝙄𝘾𝘼𝘾𝙄𝙊𝙉\n"
        local verificar
        bot+="•────•──────────•────•\n"
        bot+=" $verificar\n"
        bot+="•────•──────────•────•\n"
        [[ ! -z ${callback_query_message_chat_id[$id]} ]] && var=${callback_query_message_chat_id[$id]} || var=${message_chat_id[$id]}
        ShellBot.sendMessage --chat_id $var \
            --text "$bot" \
            --parse_mode html
        return 0
        ;;
                    /MI_ACCESO|/[Mm]enu|[Mm]enu|/[Ss]tart|[Ss]tart|[Cc]omensar|/[Cc]omensar) menu_src &;;
                    /[Aa]yuda|[Aa]yuda|[Hh]elp|/[Hh]elp) ayuda_src &;;
                    /[Ii]d|/[Ii]D) myid_src &;;
                    /[Aa]dd)newid;;
                    /[Dd]el)rmid;;
                    /[Ii]p) ipgeo;;
                    /[Rr]em) remoip;;
                    /[Pp]ass) passip;;
                    /[Pp]ower) start_gen &;;
                    /[Rr]eseller) newres;;
                    /[Aa]utodel|[Aa]utodel) autodel_id;;
                    /[Dd]elresell) rm_resell &;;
                    /[Kk]eylatam|/[Gg]elatam|[Gg]elatam|[Kk]eylatam) generar &;;
                    #/[Kk]eylat|/[Gg]elat|[Gg]elat|[Kk]eylat) gerar_key &;;
                    /[Kk]eygens|/[Gg]erar|[Gg]erar|[Kk]eygens) gerar_keyc &;;
                    /[Bb]uscar|[Bb]uscar) reply &;;
                    /[Ii]nfosys) infosys_src &;;
                    /[Ii]dgen|[Ii]dgen) listID_GEN &;;
                    /[Cc]atip|[Cc]atip) list_IP &;;
                    /[Dd]elid) replydos &;;
                    /[Aa]ddban) idban &;;
                    /[Ll]ist) listID_src &;;
                    /[Ll]iscup) listIDcup_src &;;
                    /[Uu]ser) criarteste2 &;;
                    /[Uu]ser3) criarteste3 &;;
                    /[Ss]sl) sslt &;;
                    /[Mm]enub) menublok &;;
                    /[Mm]enurem) menu_dos &;;
                    /[Uu]p) updates &;;
                    /[Ii]plist) show_connected_ip&;;
                    /[Rr]eip) remove_connection &;;
                    /[Ll]iskey) listkey_src &;;
                    /[Dd]ari) replydos & ;;
                    /[Ii]nstalador) link_src &;;
                    /[Cc]a) filesdos &;;
                    /[Dd]arnix) autovps &;;
                    /[Rr]eser) restart_genbot &;;
                	/ippp)domain-IP -ip &;;
                	/[Dd]omain|[.@/+-_!?][Dd]omain)domain-IP&;;
			     	/createsubd)createsubd "${comando[1]}" "${comando[2]}" &;;
				   /[Aa]ddip) newip &;;
				[/?!+-.$][Rr]un-cmd)run_cm ${comando[1]} ${comando[2]} &;;
				 	/[Dd]omain)domain-IP&;;
                    /*|*) invalido_fun &;;
                esac
            fi
            del_msj
        fi
    done
done
