+ added file upload by id

master
Dominika Liberda 2021-09-30 15:08:19 +02:00
parent 40bbce9039
commit 53cfd77b2f
1 changed files with 19 additions and 9 deletions

28
tg.sh
View File

@ -12,7 +12,7 @@ function _unescape_text() {
sed -E 's/\\/&lauraiscute/g;s/\\lauraiscute\\lauraiscute\\lauraiscute/\\/;s/\\lauraiscute//g' <<< "$1"
}
# tg_send(chat, text, file, type)
# tg_send(chat, text, file, type, [id])
function tg_send() {
text="$(_escape_text "$2")"
if [[ $3 != '' ]]; then
@ -25,13 +25,23 @@ function tg_send() {
[[ $4 == 'animation' ]] && local type="Animation"
[[ $4 == 'voice' ]] && local type="Voice"
[[ $4 == 'video_note' ]] && local type="VideoNote"
curl -s \
-F chat_id=$1 \
-F caption="$text" \
-F parse_mode=$PARSE_MODE \
-F $type_snake=@$3 \
"https://api.telegram.org/bot${TELEGRAM_TOKEN}/send${type}"
[[ $4 == 'sticker' ]] && local type="Sticker"
if [[ $3 == "remoteFileId" ]]; then
curl -s \
-F chat_id=$1 \
-F caption="$text" \
-F parse_mode=$PARSE_MODE \
-F $type_snake=$5 \
"https://api.telegram.org/bot${TELEGRAM_TOKEN}/send${type}"
else
curl -s \
-F chat_id=$1 \
-F caption="$text" \
-F parse_mode=$PARSE_MODE \
-F $type_snake=@$3 \
"https://api.telegram.org/bot${TELEGRAM_TOKEN}/send${type}"
fi
else
curl -s \
-F chat_id=$1 \
@ -302,7 +312,7 @@ function tg_start() {
event[sticker_is_animated]="${_tmp[4]}"
event[sticker_file_id]="${_tmp[5]}"
event[sticker_file_unique_id]="${_tmp[6]}"
event[sticker_file_size]="${_tmp[6]}"
event[sticker_file_size]="${_tmp[7]}"
unset _tmp
_on_sticker