-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTD
More file actions
127 lines (109 loc) · 2.62 KB
/
Copy pathTD
File metadata and controls
127 lines (109 loc) · 2.62 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
#!/bin/bash
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 conf() {
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 cfg() {
cfg=~/.telegram-bot/TD-$1/config
if [[ ! -f $cfg ]]; then
echo 'default_profile = "TD-'$1'";
TD-'$1' = {
config_directory = "TD-'$1'";
test = false;
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 loginbot() {
logdr=~/.telegram-bot/TD-$1/log.txt
if [ ! -f $logdr ]; then
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
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
setsudo $1
conf $1
cfg $1
botmod $1
echo -e "\n\033[38;0;0m\n"
fi
}
autolaunch() {
COUNTER=0
while [ $COUNTER -lt 9 ]; do
sleep 1
let COUNTER=COUNTER+1
sudo tmux kill-session -t TD-$1
sudo tmux new-session -d -s TD-$1 "./telegram-bot -d -c ~/.telegram-bot/TD-$1/config"
sudo tmux detach -s TD-$1
sleep 2
printf "\r\033[1;31m Tabchi bot $COUNTER runing ..."
done
printf "\n\e[38;0;0m"
}
if [ ! -d ~/.telegram-bot ]; then
mkdir ~/.telegram-bot
elif [ "$1" = "upgrade" ]; then
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
sudo tmux kill-session -t TD-$1
sudo tmux new-session -s TD-$1 "./telegram-bot -d -c ~/.telegram-bot/TD-$1/config"
sudo tmux detach -s TD-$1
done
else
autolaunch
fi