forked from iicc1/TgBash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.sh
268 lines (226 loc) · 7.61 KB
/
commands.sh
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
#!/bin/bash
#*.*encoding=utf-8*.*
# Edit your commands in this file.
if [ "$1" = "source" ];then
FILE_REGEX='/'
else
# Return chats and gbans in console
send_register
# Load langs
source lang.sh
# Load inline keyboards
source settings/inline_keyboards.sh
if ! tmux ls | grep -v send | grep -q $copname; then
[ ! -z ${URLS[*]} ] && {
curl -s ${URLS[*]} -o $NAME
send_file "${CHAT[ID]}" "$NAME" "$CAPTION"
rm "$NAME"
}
[ ! -z ${LOCATION[*]} ] && send_location "${CHAT[ID]}" "${LOCATION[LATITUDE]}" "${LOCATION[LONGITUDE]}"
# Inline
if [ $INLINE == 1 ]; then
# Inline examples
if [[ ${iQUERY[MSG]} == photo ]]; then
answer_inline_query "${iQUERY[ID]}" "photo" "http://blog.techhysahil.com/wp-content/uploads/2016/01/Bash_Scripting.jpeg" "http://blog.techhysahil.com/wp-content/uploads/2016/01/Bash_Scripting.jpeg"
fi
if [[ ${iQUERY[MSG]} == sticker ]]; then
answer_inline_query "${iQUERY[ID]}" "cached_sticker" "BQADBAAD_QEAAiSFLwABWSYyiuj-g4AC"
fi
if [[ ${iQUERY[MSG]} == gif ]]; then
answer_inline_query "${iQUERY[ID]}" "gif" "http://www.compciv.org/files/images/cli/cli-bash-script-hello-world.gif" "http://www.compciv.org/files/images/cli/cli-bash-script-hello-world.gif"
fi
if [[ ${iQUERY[MSG]} == github ]]; then
answer_inline_query "${iQUERY[ID]}" "article" "GitHub" "This is a bot bash. Get code [here](https://github.com/iicc1/TgBash)" "By @iicc1 and @Jarriz" "https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png"
fi
fi
fi
# Services
# If is new member then
if [ "$NEW_MEMBER" ]; then
send_markdown_message "${CHAT[ID]}" "Welcome ${NEW_MEMBER[FIRST_NAME]} @${NEW_MEMBER[USERNAME]} to *${CHAT[TITLE]}*"
fi
# If is kicked then
if [ "$OUT_MEMBER" ]; then
send_markdown_message "${CHAT[ID]}" "Bye @${OUT_MEMBER[USERNAME]}, I see you later..."
fi
# If is a forward from private (user) then
if [ "$FORWARD" ]; then
if [ "${CHAT[TYPE]}" == private ]; then
send_markdown_message "${CHAT[ID]}" "*${lang[ID]}* ${FORWARD[ID]}" "$reply"
fi
if [ "${CHAT[TYPE]}" != private ]; then
exit
fi
fi
# If is a forward from chat (channel) then
if [ "$FORWARD_CHAT" ]; then
if [ "${CHAT[TYPE]}" == private ]; then
send_markdown_message "${CHAT[ID]}" "${lang[CHANNEL_ID]} ${FORWARD_CHAT[ID]}
*${lang[TITLE]}* ${FORWARD_CHAT[TITLE]}
*${lang[USER]}* \`@${FORWARD_CHAT[USERNAME]}\`" "$reply"
fi
if [ "${CHAT[TYPE]}" != private ]; then
exit
fi
fi
# If is gbanned then
if [ $GBAN == 1 ]; then
kick_chat_member "${CHAT[ID]}" "${GBAN}"
kick_chat_member "${CHAT[ID]}" "${NEW_MEMBER[ID]}"
exit
fi
# User commands
echo $MESSAGE | grep -w "/echo"
if [ $? == 0 ]; then
send_markdown_message "${CHAT[ID]}" "${ENTRY[ALL]}"
fi
echo $MESSAGE | grep -w "/rev"
if [ $? == 0 ]; then
change=$(echo ${ENTRY[ALL]} | rev)
send_markdown_message "${CHAT[ID]}" "$change"
fi
echo $MESSAGE | grep -w "/ct"
if [ $? == 0 ]; then
if [ ${CHAT[TYPE]} == private ]; then
MESSAGE=$(echo $MESSAGE | cut -d " " -f2-)
forward "${ADMINS}" "${CHAT[ID]}" "${MESSAGE[ID]}"
send_markdown_message "${CHAT[ID]}" "${lang[MD]}"
fi
if [ ${CHAT[TYPE]} != private ]; then
exit
fi
fi
echo $MESSAGE | grep -w "/calc"
if [ $? == 0 ]; then
MESSAGE=$(echo $MESSAGE | cut -d " " -f2 | sed 's/\+/%2B/g' | sed 's/(/%28/g' | sed 's/)/%29/g')
EXPR=$(curl -s http://api.mathjs.org/v1/?expr=$MESSAGE)
send_markdown_message "${CHAT[ID]}" "*${EXPR}*" "$reply"
fi
echo $MESSAGE | grep "^/res"
if [ $? == 0 ]; then
USR=$(echo $MESSAGE | cut -d " " -f2)
getchat "$USR"
id=$(echo $res | jq -r '.result .id')
type=$(echo $res | jq -r '.result .type')
title=$(echo $res | jq -r '.result .title')
username=$(echo $res | jq -r '.result .username')
first_name=$(echo $res | jq -r '.result .first_name')
last_name=$(echo $res | jq -r '.result .last_name')
send_markdown_message "${CHAT[ID]}" "@$username ($id)
*Firstname* _ $first_name _
*Lastname* _ $last_name _
*Title* _ $title _
*Type* _ $type _"
exit
fi
case $MESSAGE in
'/start' | '/help')
if [ ${CHAT[TYPE]} == private ]; then
send_action "${CHAT[ID]}" "typing"
send_markdown_message "${CHAT[ID]}" "${lang[START]}"
fi
if [ ${CHAT[TYPE]} != private ]; then
send_markdown_message "${CHAT[ID]}" "${lang[PRIVATE]}"
fi
;;
'/calculator')
startproc "./calculator"
;;
'/getinfo')
send_markdown_message "${CHAT[ID]}" "*${lang[USER]}* @${REPLY[USERNAME]}
*${lang[ID]}* ${REPLY[ID]}" "$reply"
;;
'/info')
send_inline_keyboard "${CHAT[ID]}" "${lang[INFO]}" "${inline_keyboard[help]}" "$reply"
;;
'/kickme')
kick_chat_member "${CHAT[ID]}" "${USER[ID]}"
unban_chat_member "${CHAT[ID]}" "${USER[ID]}"
;;
'/myinfo')
send_markdown_message "${CHAT[ID]}" "*${lang[ID]}* ${USER[ID]}
*${lang[USER]}* @${USER[USERNAME]}
*${lang[NAME]}* ${USER[FIRST_NAME]}
*${lang[LASTNAME]}* ${USER[LAST_NAME]}"
;;
'/getmembers')
getmembers "${CHAT[ID]}" "${lang[GETMEMBERS]}
"
;;
'/cancel')
if tmux ls | grep -q $copname; then killproc && send_markdown_message "${CHAT[ID]}" "*Command canceled*.";else send_markdown_message "${CHAT[ID]}" "*No command is currently running*.";fi
;;
*)
if tmux ls | grep -v send | grep -q $copname;then inproc; else send_message "${CHAT[ID]}" "" "safe";fi
;;
esac
# Admin commands
if [ $ADMIN == 1 ]; then
echo $MESSAGE | grep -w "/broadcast"
if [ $? == 0 ]; then
send_markdown_message "${USER[ID]}" "${lang[BC]}
_${ENTRY[ALL]}_" "$reply"
shift
for f in $(cat count);do send_markdown_message ${f//COUNT} "${ENTRY[ALL]}"; $sleep;done
fi
echo $MESSAGE | grep -w "/su"
if [ $? == 0 ]; then
MESSAGE=$(echo $MESSAGE | cut -d " " -f2-)
COMMAND=$($MESSAGE)
send_markdown_message "${CHAT[ID]}" "*${COMMAND}*"
fi
echo $MESSAGE | grep -w "/setlang"
if [ $? == 0 ]; then
setlang=$(set_lang)
if [ "$setlang" == true ]; then
sed -i '6 s/'$LANG'/'${ENTRY[1]}'/g' lang.sh
send_markdown_message "${CHAT[ID]}" "${lang[LANG]} *${ENTRY[1]}*" "$reply"
else
send_markdown_message "${CHAT[ID]}" "${lang[LANG_NO_AVAILABLE]}" "$reply"
fi
fi
case $MESSAGE in
'/leavechat')
send_markdown_message "${USER[ID]}" "${lang[LEAVECHAT]}"
leave_chat "${CHAT[ID]}"
;;
'/newadmin')
echo "${REPLY[ID]}," >> settings/admins
send_markdown_message "${CHAT[ID]}" "${lang[ID]} ${REPLY[ID]} ${lang[NEWADMIN]}" "$reply"
;;
'/kick')
kick_chat_member "${CHAT[ID]}" "${REPLY[ID]}"
unban_chat_member "${CHAT[ID}" "${REPLY[ID]}"
;;
'/ban')
kick_chat_member "${CHAT[ID]}" "${REPLY[ID]}"
;;
'/unban')
unban_chat_member "${CHAT[ID]}" "${REPLY[ID]}"
;;
'/gban')
echo "[${DATE[YMD]} --> ${REPLY[FIRST_NAME]} ${REPLY[LAST_NAME]} @${REPLY[USERNAME]} (${REPLY[ID]})]" >> settings/gbans
send_markdown_message "${CHAT[ID]}" "${lang[ID]} ${REPLY[ID]} *${lang[GBANNED]}.*"
kick_chat_member "${CHAT[ID]}" "${REPLY[ID]}"
;;
'/ungban')
sed -i "/${REPLY[ID]}/d" settings/gbans
send_markdown_message "${CHAT[ID]}" "ID: ${REPLY[ID]} *${lang[UNGBANNED]}*."
unban_chat_member "${CHAT[ID]}" "${REPLY[ID]}"
;;
'/infobot')
send_markdown_message "${CHAT[ID]}" "*${lang[NAME]}* ${BOT[NAME]}
*${lang[USER]}* @${BOT[USERNAME]}
*${lang[ID]}* ${BOT[ID]}" "$reply"
;;
'/sudos')
send_markdown_message "${CHAT[ID]}" "${lang[SUDOS]}
${ADMINS}"
;;
'/ip')
IP=$(curl -s http://api.ipify.org)
send_markdown_message "${CHAT[ID]}" "${lang[IP]} *$IP*"
;;
esac
fi
fi