-
Notifications
You must be signed in to change notification settings - Fork 30
/
TD
executable file
·286 lines (238 loc) · 6.44 KB
/
TD
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#!/bin/bash
logo() {
declare -A logo
seconds="0.003"
logo[0]=" __ __ ___ __ "
logo[1]=" / /_ ___ _ / |/ / ___ __ _ / / ___ ____"
logo[2]="/ __/ / _ '/ / /|_/ / / -_) / ' \ / _ \/ -_) / __/"
logo[3]="\__/ \_, / /_/ /_/ \__/ /_/_/_//_.__/\__/ /_/ "
logo[4]=" /___/ "
logo[5]=" www.tgMember.com "
logo[6]=" coded by "
logo[7]=" Sajjad Taheri "
printf "\e[1;33m\t"
for i in ${!logo[@]}; do
for x in `seq 0 ${#logo[$i]}`; do
printf "${logo[$i]:$x:1}"
sleep $seconds
done
printf "\n\t"
done
printf "\n"
}
lualibs=(
'luasec'
'redis-lua'
'fakeredis'
'serpent'
'--server=http://luarocks.org/dev openssl'
)
pkg=(
'autoconf'
'libjansson-dev'
'libpython-dev'
'libnotify-dev'
'wget'
'screen'
'tmux'
'make'
'unzip'
'luarocks'
'libjansson4'
'libstdc++6'
'libconfig9'
'gcc-4.9'
'g++-4.9'
)
make_progress() {
exe=`lua <<-EOF
print(tonumber($1)/tonumber($2)*100)
EOF
`
echo ${exe:0:4}
}
download_libs_lua() {
local i
for ((i=0;i<${#lualibs[@]};i++)); do
printf "\r\33[2K"
printf "\rtgMember: wait... [`make_progress $(($i+1)) ${#lualibs[@]}`%%] [$(($i+1))/${#lualibs[@]}] ${lualibs[$i]}"
sudo luarocks install ${lualibs[$i]} &>> .logluarocks.txt
done
sleep 0.2
cd ..; rm -rf luarocks-2.2.2*
}
configure() {
dir=$PWD
wget http://luarocks.org/releases/luarocks-2.2.2.tar.gz &>> .install.log
tar zxpf luarocks-2.2.2.tar.gz &>> .install.log
cd luarocks-2.2.2
./configure &>> .install.log
make bootstrap &>> .install.log
if [[ ${1} != "--no-download" ]]; then
download_libs_lua
rm -rf luarocks*
fi
}
installation() {
for i in $(seq 1 100); do
sleep 0.2
if [ $i -eq 100 ]; then
echo -e "XXX\n100\nDone!\nXXX"
elif [ $(($i % 6)) -eq 0 ]; then
let "phase = $i / 6"
echo -e "XXX\n$i\n${pkg[phase]}\nXXX"
sudo apt-get install -y ${pkg[$phase]} &>> .install.log
else
echo $i
fi
done | whiptail --title 'tgMember tdAds robot Installing and Configuration' --gauge "${pkg[0]}" 6 60 0
}
function update() {
sudo git pull
sudo git fetch --all
sudo git reset --hard origin/master
sudo git pull origin master
sudo chmod 7777 TD
}
function cliconf() {
dirbot=~/.telegram-bot/td-$1/td.lua
if [[ ! -f $dirbot ]]; then
echo "Ads_id = '$1'
require('TD')
function tdbot_update_callback(data)
Doing(data, Ads_id)
end" >> $dirbot
fi
}
function apiconf() {
dirbot=~/.telegram-bot/td-$1/td.lua
if [[ ! -f $dirbot ]]; then
echo "Ads_id = '$1'
require('TD')
function tdbot_update_callback(data)
Doing(data, Ads_id)
end" >> $dirbot
fi
}
function cfg() {
cfg=~/.telegram-bot/td-$1/config
if [[ ! -f $cfg ]]; then
echo 'default_profile = "td-'$1'";
td-'$1' = {
config_directory = "td-'$1'";
lua_script = "td.lua";
};' >> $cfg
fi
}
function setsudo() {
echo -e "\033[38;5;27m\n"
read -p 'put your user-Id :' -e input
redis-cli sadd tg:$1:sudo $input
}
function loginbot() {
logdr=~/.telegram-bot/td-$1/log.txt
if [ ! -f $logdr ]; then
cliconf $1
echo -e "\033[38;5;208m\n\033[6;48m\n"
read -p 'Phone number :' -e input
./telegram-bot -c ~/.telegram-bot/td-$1/config --login --phone=$input
fi
}
function loginapi() {
logdr=~/.telegram-bot/td-$1/log.txt
if [ ! -f $logdr ]; then
apiconf $1
echo -e "\033[38;5;208m\n\033[6;48m\n"
read -p 'TOKEN :' -e input
./telegram-bot -c ~/.telegram-bot/td-$1/config --login --bot=$input
fi
}
function botmod() {
echo -e "\033[38;5;208mSelect your Robot Mod Configuration\033[1;208m"
read -p "API [A/a] - CLI [C/c]"
if [ "$REPLY" == "A" ] || [ "$REPLY" == "a" ]; then
loginapi $1
elif [ "$REPLY" == "C" ] || [ "$REPLY" == "c" ]; then
loginbot $1
fi
}
runbt() {
drbt=~/.telegram-bot/td-$1
if [ ! -d $drbt ]; then
mkdir ~/.telegram-bot/td-$1
setsudo $1
cfg $1
botmod $1
echo -e "\n\033[38;0;0m\n"
fi
}
autolaunch() {
while true; do
COUNTER=0
while [ $COUNTER -lt 19 ]; do
let COUNTER=COUNTER+1
tmux kill-session -t td-$COUNTER &>/dev/null
tmux new-session -d -s td-$COUNTER "./telegram-bot -c ~/.telegram-bot/td-$COUNTER/config" &>/dev/null
tmux detach -s td-$COUNTER &>/dev/null
printf "\r\033[1;31m tdAds bot $COUNTER runing ..."
rm -rf ~/.telegram-bot/td-$COUNTER/files/*
rm -rf ~/.telegram-bot/td-$COUNTER/data/thumbnails/*
sleep 1
done
printf "\e[38;0;0m"
logo
sleep 180
done
}
if [ ! -f "telegram-bot" ]; then
apt-get -y update
apt-get -y upgrade
apt-get install -y libreadline-dev libconfig-dev libssl-dev liblua5.2-dev lua-socket lua-sec lua-expat git libevent-dev lua-socket lua5.2 liblua5.2 redis-server software-properties-common g++ libconfig++-dev lua-lgi libreadline5 expat libexpat1-dev whiptail
apt-get -y update
apt-get -y upgrade
add-apt-repository -y ppa:ubuntu-toolchain-r/test
apt-get -y update
wget --no-check-certificate https://valtman.name/files/telegram-bot-180817-nightly-linux
mv telegram-bot-180817-nightly-linux telegram-bot
chmod 777 telegram-bot
clear
logo
echo -e "\033[0;00m\n"
installation
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9 &>> .install.log
echo -e "\n\033[1;31mplease waite ... .. .\nThis operation may take a few minutes\n"
apt-get -y update &>> .install.log
apt-get -y upgrade &>> .install.log
apt-get -y dist-upgrade &>> .install.log
apt-get autoclean &>> .install.log
apt-get -y autoremove &>> .install.log
printf "\n\e[38;5;213m\t"
configure
echo -e "\033[0;00m\n"
for ((i=0;i<101;i++)); do
printf "\rConfiguring... [%i%%]" $i
sleep 0.009
done
echo -e "\n\033[1;32mInstall Complete\033[0;00m\n"
service redis-server restart &>> .install.log
echo -e "Create and launch new bot with \033[1;28m ./TD 1 \033[0;00m command.\n"
rm -rf README.md
chmod 7777 TD
mkdir ~/.telegram-bot
elif [ "$1" = "upgrade" ]; then
update
wget --no-check-certificate https://valtman.name/files/telegram-bot-180817-nightly-linux &>> .install.log
mv telegram-bot-180817-nightly-linux telegram-bot
chmod 777 telegram-bot
elif [[ "$1" =~ ^[0-9]+$ ]]; then
runbt $1
while true; do
tmux kill-session -t td-$1
tmux new-session -s td-$1 "./telegram-bot -c ~/.telegram-bot/td-$1/config | grep -v '{'"
tmux detach -s td-$1
rm -rf ~/.telegram-bot/td-$1/files/*
rm -rf ~/.telegram-bot/td-$1/data/thumbnails/*
done
else
autolaunch
fi