forked from FighterTunnel/BotVPN
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathstart
More file actions
140 lines (127 loc) · 5.92 KB
/
start
File metadata and controls
140 lines (127 loc) · 5.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
# Colors
green="\e[38;5;82m"
red="\e[38;5;196m"
neutral="\e[0m"
orange="\e[38;5;130m"
blue="\e[38;5;39m"
yellow="\e[38;5;226m"
purple="\e[38;5;141m"
bold_white="\e[1;37m"
reset="\e[0m"
pink="\e[38;5;205m"
print_rainbow() {
local text="$1"
local length=${#text}
local start_color=(0 5 0)
local mid_color=(0 200 0)
local end_color=(0 5 0)
for ((i = 0; i < length; i++)); do
local progress=$(echo "scale=2; $i / ($length - 1)" | bc)
if (($(echo "$progress < 0.5" | bc -l))); then
local factor=$(echo "scale=2; $progress * 2" | bc)
r=$(echo "scale=0; (${start_color[0]} * (1-$factor) + ${mid_color[0]} * $factor)/1" | bc)
g=$(echo "scale=0; (${start_color[1]} * (1-$factor) + ${mid_color[1]} * $factor)/1" | bc)
b=$(echo "scale=0; (${start_color[2]} * (1-$factor) + ${mid_color[2]} * $factor)/1" | bc)
else
local factor=$(echo "scale=2; ($progress - 0.5) * 2" | bc)
r=$(echo "scale=0; (${mid_color[0]} * (1-$factor) + ${end_color[0]} * $factor)/1" | bc)
g=$(echo "scale=0; (${mid_color[1]} * (1-$factor) + ${end_color[1]} * $factor)/1" | bc)
b=$(echo "scale=0; (${mid_color[2]} * (1-$factor) + ${end_color[2]} * $factor)/1" | bc)
fi
printf "\e[38;2;%d;%d;%dm%s" "$r" "$g" "$b" "${text:$i:1}"
done
echo -e "$reset"
}
cek_status() {
pm2 status | grep -q sellvpn && echo "aktif" || echo "nonaktif"
}
setup_bot() {
timedatectl set-timezone Asia/Jakarta || echo -e "${red}Failed to set timezone to Jakarta${neutral}"
if ! dpkg -s nodejs >/dev/null 2>&1; then
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - || echo -e "${red}Failed to download Node.js setup${neutral}"
apt-get install -y nodejs || echo -e "${red}Failed to install Node.js${neutral}"
npm install -g npm@latest
else
echo -e "${green}Node.js is already installed, skipping...${neutral}"
fi
if [ ! -f /root/BotVPN/app.js ]; then
git clone https://github.com/AutoFTbot/BotVPN.git /root/BotVPN
fi
if ! npm list --prefix /root/BotVPN express telegraf axios moment sqlite3 >/dev/null 2>&1; then
npm install --prefix /root/BotVPN sqlite3 express crypto telegraf axios dotenv
fi
if [ -n "$(ls -A /root/BotVPN)" ]; then
chmod +x /root/BotVPN/*
fi
}
server_app() {
clear
echo -e "${orange}─────────────────────────────────────────${neutral}"
echo -e " ${green}.:::. BOT SELLVPN TELEGRAM .:::. ${neutral}"
echo -e "${orange}─────────────────────────────────────────${neutral}"
echo -e " ${green}•${neutral} server create user"
echo -e " ${green}•${neutral} server delete user"
echo -e " ${green}•${neutral} server addsaldo user"
echo -e " ${green}•${neutral} server ceksaldo user"
echo -e "${orange}─────────────────────────────────────────${neutral}"
read -p "Masukkan token bot: " token
while [ -z "$token" ]; do
read -p "Masukkan token bot: " token
if [ -z "$token" ]; then
echo -e "${red}Token bot tidak boleh kosong. Silakan coba lagi.${neutral}"
fi
done
while [ -z "$adminid" ]; do
read -p "Masukkan admin ID: " adminid
if [ -z "$adminid" ]; then
echo -e "${red}Admin ID tidak boleh kosong. Silakan coba lagi.${neutral}"
fi
done
while [ -z "$namastore" ]; do
read -p "Masukkan nama store: " namastore
if [ -z "$namastore" ]; then
echo -e "${red}Nama store tidak boleh kosong. Silakan coba lagi.${neutral}"
fi
done
while [ -z "$dataqris" ]; do
read -p "Masukkan DATA QRIS: " dataqris
if [ -z "$dataqris" ]; then
echo -e "${red}DATA QRIS tidak boleh kosong. Silakan coba lagi.${neutral}"
fi
done
while [ -z "$username_orkut" ]; do
read -p "Masukkan USERNAME ORDERKUOTA: " username_orkut
if [ -z "$username_orkut" ]; then
echo -e "${red}USERNAME ORDERKUOTA tidak boleh kosong. Silakan coba lagi.${neutral}"
fi
done
while [ -z "$auth_token" ]; do
read -p "Masukkan AUTH TOKEN: " auth_token
if [ -z "$auth_token" ]; then
echo -e "${red}AUTH TOKEN tidak boleh kosong. Silakan coba lagi.${neutral}"
fi
done
while [ -z "$groupid" ]; do
read -p "Masukkan GROUP ID (ID grup Telegram, contoh: -1001234567890): " groupid
if [ -z "$groupid" ]; then
echo -e "${red}GROUP ID tidak boleh kosong. Silakan coba lagi.${neutral}"
fi
done
rm -f /root/BotVPN/.vars.json
echo "{\n \"BOT_TOKEN\": \"$token\",\n \"USER_ID\": \"$adminid\",\n \"NAMA_STORE\": \"$namastore\",\n \"GROUP_ID\": \"$groupid\",\n \"PORT\": \"6969\",\n \"DATA_QRIS\": \"$dataqris\",\n \"USERNAME_ORKUT\": \"$username_orkut\",\n \"AUTH_TOKEN\": \"$auth_token\"\n}" >/root/BotVPN/.vars.json
pm2 start /root/BotVPN/app.js --name sellvpn --env production -- --token "$token" --adminid "$adminid" --namastore "$namastore" --dataqris "$dataqris" --username_orkut "$username_orkut" --auth_token "$auth_token"
pm2 save
printf "\033[5A\033[0J"
echo -e " Status Server is "$(cek_status)""
echo -e "${orange}─────────────────────────────────────────${neutral}"
echo -e "${green}Bot has been installed and running.${neutral}"
echo -e "${green}Type ${bold_white}/start${neutral} or ${bold_white}menu${neutral} in the telegram bot${neutral}"
}
if [[ ${1} == "sellvpn" ]]; then
setup_bot
server_app
else
echo -e "${red}Invalid command. Use: ${yellow}start sellvpn${neutral}"
exit 1
fi