forked from tgMember/tdAds
-
Notifications
You must be signed in to change notification settings - Fork 1
/
TD
executable file
·183 lines (164 loc) · 4.43 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
#!/bin/bash
function logo() {
declare -A logo
seconds="0.002"
logo[0]="_____ ______ ___ ______ "
logo[1]="__ /________ _ ___ |/ /_____ _______ ___ ___ /_ _____ ________"
logo[2]="_ __/__ __ / __ /|_/ / _ _ \__ __ __ \__ __ \_ _ \__ ___/"
logo[3]="/ /_ _ /_/ / _ / / / / __/_ / / / / /_ /_/ // __/_ / "
logo[4]="\__/ _\__, / /_/ /_/ \___/ /_/ /_/ /_/ /_.___/ \___/ /_/ "
logo[5]=" /____/ "
logo[6]=" @tgMember ****** @sajjad_021 "
printf "\e[38;5;154m\n\e[38;7;27m\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"
}
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'
serpent = require('serpent')
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
cat API.lua >> ~/.telegram-bot/td-$1/td.lua
sed -i 's/ID/'$1'/g' ~/.telegram-bot/td-$1/td.lua
fi
}
function cfg() {
cfg=~/.telegram-bot/td-$1/config
if [[ ! -f $cfg ]]; then
echo 'default_profile = "td-'$1'";
td-'$1' = {
config_directory = "td-'$1'";
test = false;
language = "en";
log_chat = "-1001116064938";
log_admin_actions = true;
bug_reports_chat = "-1001116064938";
respond_to_misc = true;
max_copypasta_length = 300;
debug = true;
use_file_db = true;
use_file_gc = true;
file_readable_names = true;
use_secret_chats = false;
use_chat_info_db = true;
use_message_db = true;
logname = "log.txt";
verbosity = 0;
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 setsudoapi() {
echo -e "\033[38;5;27m\n"
read -p 'put your user-Id :' -e input
sed -i 's/180191663/'$input'/g' ~/.telegram-bot/td-$1/td.lua
}
function loginbot() {
logdr=~/.telegram-bot/td-$1/log.txt
if [ ! -f $logdr ]; then
cliconf $1
setsudo $1
echo -e "\033[38;5;208m\n\033[6;48m\n"
read -p 'Phone number :' -e input
./telegram-bot -p td-$1 -L log.txt --login --phone=$input
fi
}
function loginapi() {
logdr=~/.telegram-bot/td-$1/log.txt
if [ ! -f $logdr ]; then
apiconf $1
setsudoapi $1
echo -e "\033[38;5;208m\n\033[6;48m\n"
read -p 'TOKEN :' -e input
./telegram-bot -p td-$1 -L log.txt --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
botmod $1
cfg $1
echo -e "\n\033[38;0;0m\n"
fi
}
autolaunch() {
while true; do
killall tmux &>> .telegram-bot.log
killall telegram-bot &>> .telegram-bot.log
service redis-server restart &>> .telegram-bot.log
systemctl daemon-reload &>> .telegram-bot.log
clear
COUNTER=0
while [ $COUNTER -lt 9 ]; do
let COUNTER=COUNTER+1
tmux kill-session -t td-$COUNTER &> .telegram-bot.log &
tmux new-session -d -s td-$COUNTER "./telegram-bot -d -c ~/.telegram-bot/td-$COUNTER/config" &> .telegram-bot.log &
tmux detach -s td-$COUNTER &> .telegram-bot.log &
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 3
done
printf "\e[38;0;0m"
logo
exit
sleep 1800
done
}
if [ ! -d ~/.telegram-bot ]; then
mkdir ~/.telegram-bot
elif [ "$1" = "upgrade" ]; then
luarocks install dkjson
sudo rm -rf telegram-bot
update
wget https://valtman.name/files/telegram-bot-$(date +%y%m%d)-nightly-linux
mv telegram-bot-$(date +%y%m%d)-nightly-linux telegram-bot; chmod +x 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 -d -c ~/.telegram-bot/td-$1/config"
tmux detach -s td-$1
rm -rf ~/.telegram-bot/td-$COUNTER/files/*
rm -rf ~/.telegram-bot/td-$COUNTER/data/thumbnails/*
done
else
autolaunch
fi