-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathC
More file actions
154 lines (138 loc) · 3.94 KB
/
C
File metadata and controls
154 lines (138 loc) · 3.94 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
# Launch created by Amir Bagheri
tgcli_version="170904-nightly"
luarocks_version=2.4.2
lualibs=(
'redis-lua'
'serpent'
)
today=`date +%F`
get_sub() {
local flag=false c count cr=$'\r' nl=$'\n'
while IFS='' read -d '' -rn 1 c; do
if $flag; then
printf '%c' "$c"
else
if [[ $c != $cr && $c != $nl ]]; then
count=0
else
((count++))
if ((count > 1)); then
flag=true
fi
fi
fi
done
}
function get_tgcli_version() {
echo "$tgcli_version"
}
function download_libs_lua() {
if [[ ! -d "logs" ]]; then mkdir logs; fi
if [[ -f "logs/logluarocks_${today}.txt" ]]; then rm logs/logluarocks_${today}.txt; fi
local i
for ((i=0;i<${#lualibs[@]};i++)); do
printf "\r\33[2K"
printf "\rCerNerCompany: wait... [`make_progress $(($i+1)) ${#lualibs[@]}`%%] [$(($i+1))/${#lualibs[@]}] ${lualibs[$i]}"
./.luarocks/bin/luarocks install ${lualibs[$i]} &>> logs/logluarocks_${today}.txt
done
sleep 0.2
printf "\nLogfile created: $PWD/logs/logluarocks_${today}.txt\nDone\n"
rm -rf luarocks-2.2.2*
}
function configure() {
dir=$PWD
wget http://luarocks.org/releases/luarocks-${luarocks_version}.tar.gz &>/dev/null
tar zxpf luarocks-${luarocks_version}.tar.gz &>/dev/null
cd luarocks-${luarocks_version}
if [[ ${1} == "--no-null" ]]; then
./configure --prefix=$dir/.luarocks --sysconfdir=$dir/.luarocks/luarocks --force-config
make bootstrap
else
./configure --prefix=$dir/.luarocks --sysconfdir=$dir/.luarocks/luarocks --force-config &>/dev/null
make bootstrap &>/dev/null
fi
cd ..; rm -rf luarocks*
if [[ ${1} != "--no-download" ]]; then
download_libs_lua
wget --progress=bar:force https://valtman.name/files/telegram-bot-${tgcli_version}-linux 2>&1 | get_sub
mv telegram-bot-${tgcli_version}-linux telegram-bot; chmod +x telegram-bot
fi
for ((i=0;i<101;i++)); do
printf "\rConfiguring... [%i%%]" $i
sleep 0.007
done
mkdir $HOME/.telegram-bot; cat <<EOF > $HOME/.telegram-bot/config
default_profile = "main";
main = {
lua_script = "$HOME/شدفه-سحشپ/bot/bot.lua";
};
EOF
printf "\nDone\n"
}
function start_bot() {
./telegram-bot | grep -v "{"
}
function login_bot() {
./telegram-bot -p main --login --phone=${1}
}
function update_bot() {
git checkout launch.sh plugins/ lang/ bot/ libs/
git pull
echo chmod +x launch.sh | /bin/bash
version=$(echo "./launch.sh tgcli_version" | /bin/bash)
update_bot_to $version
}
function update_bot_to() {
wget --progress=bar:force https://valtman.name/files/telegram-bot-${1}-linux 2>&1 | get_sub
mv telegram-bot-${1}-linux telegram-bot; chmod +x telegram-bot
}
function show_logo_slowly() {
seconds=0.009
logo=(
"CerNer Cleaner By Amir Bagheri : CerNer Company"
)
printf "\033[38;5;208m\t"
local i x
for i in ${!logo[@]}; do
for ((x=0;x<${#logo[$i]};x++)); do
printf "${logo[$i]:$x:1}"
sleep $seconds
done
printf "\n\t"
done
printf "\n"
}
function show_logo() {
#Adding some color. By @iicc1 :D
echo -e "\033[38;5;208m"
echo -e "CerNer Cleaner By Amir Bagheri : CerNer Company"
echo -e "\n\e[36m"
}
case $1 in
install)
show_logo_slowly
configure ${2}
exit ;;
login)
echo "Please enter your phone number: "
read phone_number
login_bot ${phone_number}
exit ;;
update)
update_bot
exit ;;
tgcli_version)
get_tgcli_version
exit ;;
help)
echo "Commands available:"
echo " install - First command to install all repos and download binary."
echo " login - Access into your telegram account."
echo " update-to - Write a version to update binary (from vysheng website)."
echo " help - Shows this message."
exit ;;
esac
show_logo
start_bot $@
exit 0