+ added file upload by id
parent
40bbce9039
commit
53cfd77b2f
28
tg.sh
28
tg.sh
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue