This repository has been archived by the owner on Mar 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
commands.sh
executable file
·166 lines (149 loc) · 7.7 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
#!/bin/bash
# Edit your commands in this file.
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
if [ "$1" = "source" ];then
# Place the token in the token file
TOKEN=$(cat token)
# Set INLINE to 1 in order to receive inline queries.
# To enable this option in your bot, send the /setinline command to @BotFather.
INLINE=1
# Set to .* to allow sending files from all locations
FILE_REGEX='.*'
else
{
if ! tmux ls | grep -v send | grep -q $copname; then
[ ! -z ${URLS[*]} ] && {
# send_file "${CHAT[ID]}" $(echo "${URLS[*]}" | sed 's/\s*//g' | tr -d '\n')
# send_message "${CHAT[ID]}" "Downloading file..."
send_message "${CHAT[ID]}" "$(echo "${URLS[*]}" | sed 's/\s*//g' | tr -d '\n') "
}
[ ! -z ${LOCATION[*]} ] && send_location "${CHAT[ID]}" "${LOCATION[LATITUDE]}" "${LOCATION[LONGITUDE]}"
# Inline
# inline query data
iUSER[FIRST_NAME]=$(echo "$res" | sed 's/^.*\(first_name.*\)/\1/g' | cut -d '"' -f3 | tail -1)
iUSER[LAST_NAME]=$(echo "$res" | sed 's/^.*\(last_name.*\)/\1/g' | cut -d '"' -f3)
iUSER[USERNAME]=$(echo "$res" | sed 's/^.*\(username.*\)/\1/g' | cut -d '"' -f3 | tail -1)
iQUERY_ID=$(echo "$res" | sed 's/^.*\(inline_query.*\)/\1/g' | cut -d '"' -f5 | tail -1)
iQUERY_MSG=$(echo "$res" | sed 's/^.*\(inline_query.*\)/\1/g' | cut -d '"' -f5 | tail -6 | head -1)
re='^[0-9]+$'
if [[ $iQUERY_ID =~ $re ]]; 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"
return
fi
if [[ $iQUERY_MSG == gif ]]; then
answer_inline_query "$iQUERY_ID" "gif" "http://i.giphy.com/149t2dI5M5nzvq.gif" "http://blog.techhysahil.com/wp-content/uploads/2016/01/Bash_Scripting.jpeg" "http://blog.techhysahil.com/wp-content/uploads/2016/01/Bash_Scripting.jpeg"
return
fi
if [[ $iQUERY_MSG == cgif ]]; then
answer_inline_query "$iQUERY_ID" "cached_gif" "BQADBAADpAADf3ErDHpXzEivjoV_Ag"
return
fi
if [[ $iQUERY_MSG == cmgif ]]; then
answer_inline_query "$iQUERY_ID" "cached_mpeg4_gif" "BQADBAADpAADf3ErDHpXzEivjoV_Ag"
return
fi
if [[ $iQUERY_MSG == zip ]]; then
answer_inline_query "$iQUERY_ID" "document" "1GB zip file" "1GB zip file" "BQADBAADbgAD_PthCPK954yXfJEDAg"
return
fi
if [[ $iQUERY_MSG == bot ]]; then
InlineQueryResult='[{"type":"file","id":"'$RANDOM'","title":"This bot","caption":"This bot","document_url":"","mime_type":""}]'
res=$(curl -s "$INLINE_QUERY" -F "inline_query_id=$iQUERY_ID" -F "results=$InlineQueryResult" -F "inline_file0=@bashbot.sh")
#"BQADBAADbgAD_PthCPK954yXfJEDAg"
return
fi
if [[ $iQUERY_MSG == 10 ]]; then
answer_inline_query "$iQUERY_ID" "document" "yay" "yay" "BQADBAADbgAD_PthCPK954yXfJEDAg"
return
fi
if [[ $iQUERY_MSG == web ]]; then
answer_inline_query "$iQUERY_ID" "article" "Telegram" "https://telegram.org/"
return
fi
if [ ! -z "$iQUERY_ID" ]; then
answer_inline_query "$iQUERY_ID" "article" "Info message" "This the official bot of the @pwrtelegram api.
The @pwrtelegram bot API is an enhanced version of telegram's bot API that has all of the official telegram bot API features plus:
* Downloading of files up to 1.5 GB in size
* Anonymous file storage (the URL of downloaded files does not contain your bot's token)
* Uploading of files up to 1.5 GB in size
* Uploading of files using an URL
* Reuploading of files using a file ID and different file type or file name.
* Uploading of any file/URL/file ID with automagical type recognition.
* Uploading of any file/URL/file ID without sending the file to a specific user.
* Automagical metadata recognition of sent files/URLs/file IDs.
* Deleting of text messages sent from the bot
* Uploading of files bigger than 5 megabytes with inline queries (supports both URLs and direct uploads)
* Automatical type recognition for files sent using answerinlinequery
* Both webhooks and getupdates are supported.
* webhook requests can be recieved even on insecure http servers.
* It is open source(https://github.com/pwrtelegram)!
* It can be installed on your own server(https://github.com/pwrtelegram/pwrtelegram-backend)!
I am connected to the beta PWRTelegram API (beta.pwrtelegram.xyz), so sometimes I might spit out some weird errors or not work at all. That means @danogentili is busy debugging the API :)
Try sending me one of the following inline queries, if you encounter some bugs send @danogentili a screenshot!
Available inline queries:
zip - Send 1gb zip file
gif - Send funny gif
cgif - Send funny cached gif
cmgif - Send funny cached mpeg4 gif
photo - Send photo
Written by Drew (@topkecleon) and Daniil Gentili (@danogentili).
http://github.com/pwrtelegram/pwrtelegram-bot"
return
fi
fi
fi
} &
case $MESSAGE in
'/question')
startproc "./question"
;;
'/info')
send_message "${CHAT[ID]}" "This is bashbot, the Telegram bot written entirely in bash."
;;
'/start'*)
send_message "${CHAT[ID]}" "This the official bot of the @pwrtelegram api.
I am basically a testing platform for the @pwrtelegram API.
The @pwrtelegram bot API is an enhanced version of telegram's bot API that has all of the official telegram bot API features plus:
* Downloading of files up to 1.5 GB in size
* Anonymous file storage (the URL of downloaded files does not contain your bot's token)
* Uploading of files up to 1.5 GB in size
* Uploading of files using an URL
* Reuploading of files using a file ID and different file type or file name.
* Uploading of any file/URL/file ID with automagical type recognition.
* Uploading of any file/URL/file ID without sending the file to a specific user.
* Automagical metadata recognition of sent files/URLs/file IDs.
* Deleting of text messages sent from the bot
* Uploading of files bigger than 5 megabytes with inline queries (supports both URLs and direct uploads)
* Automatical type recognition for files sent using answerinlinequery
* Both webhooks and getupdates are supported.
* webhook requests can be recieved even on insecure http servers.
* It is open source (https://github.com/pwrtelegram)!
* It can be installed on your own server (https://github.com/pwrtelegram/pwrtelegram-backend)!
If you send me a file, even a 1.5 gb one, I will download it, return the download URL along with some json and resend it to you.
Available commands:
• /start: Start bot and get this message.
• /info: Get shorter info message about this bot.
• /dl: Download file using file id/ URL (up to 1.5 gb).
Written by Daniil Gentili (@danogentili).
http://github.com/pwrtelegram/pwrtelegram-bot
If you encounter bugs send @danogentili a screenshot!
"
;;
'/cancel')
if tmux ls | grep -q $copname; then killproc && send_message "${CHAT[ID]}" "Command canceled.";else send_message "${CHAT[ID]}" "No command is currently running.";fi
;;
'/dl')
send_message "${CHAT[ID]}" "Usage: /dl url filename";;
'/dl'*)
echo "$MESSAGE" | grep -q "mkv" && { send_message "${CHAT[ID]}" "This bot can't download mkv files to reduce piracy."; return; };
send_message "${CHAT[ID]}" "The download was started. Send me the file you receive to get a download link."
res=$(curl -s "$FILE_DL_URL" -F "chat_id=${CHAT[ID]}" -F "file=$(echo "$MESSAGE" | sed 's/^\/dl //g;s/\s.*//g')" -F "name=$(echo "$MESSAGE" | sed 's/^\/dl //g;s/[^ ]*\s//')")
;;
*)
if tmux ls | grep -v send | grep -q $copname;then inproc;fi
;;
esac
fi