no send events when sourced

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2019-06-24 10:38:24 +02:00
parent 7843de5647
commit 3531eb9565

View File

@ -11,7 +11,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v0.94-dev2-5-gc5caf93 #### $$VERSION$$ v0.94-dev2-6-g7843de5
# #
# Exit Codes: # Exit Codes:
# - 0 sucess (hopefully) # - 0 sucess (hopefully)
@ -243,7 +243,7 @@ if [ "${BASHBOT_WGET}" = "" ] && _exists curl ; then
-H "Content-Type: application/json" | "${JSONSHFILE}" -s -b -n )" -H "Content-Type: application/json" | "${JSONSHFILE}" -s -b -n )"
BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "$res")" BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "$res")"
BOTSENT[ID]="$(JsonGetValue '"result","message_id"' <<< "$res")" BOTSENT[ID]="$(JsonGetValue '"result","message_id"' <<< "$res")"
[ "${BASHBOT_EVENT_SEND[*]}" != "" ] && event_send "send" "$@" & [ "${SOURCE}" != "yes" ] && [ "${BASHBOT_EVENT_SEND[*]}" != "" ] && event_send "send" "$@" &
} }
#$1 Chat, $2 what , $3 file, $4 URL, $5 caption #$1 Chat, $2 what , $3 file, $4 URL, $5 caption
sendUpload() { sendUpload() {
@ -256,7 +256,7 @@ if [ "${BASHBOT_WGET}" = "" ] && _exists curl ; then
res="$(curl -s -k ${BASHBOT_CURL_ARGS} "$4" -F "chat_id=$1" -F "$2=@$3;${3##*/}" | "${JSONSHFILE}" -s -b -n )" res="$(curl -s -k ${BASHBOT_CURL_ARGS} "$4" -F "chat_id=$1" -F "$2=@$3;${3##*/}" | "${JSONSHFILE}" -s -b -n )"
fi fi
BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "$res")" BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "$res")"
[ "${BASHBOT_EVENT_SEND[*]}" != "" ] && event_send "upload" "$@" & [ "${SOURCE}" != "yes" ] && [ "${BASHBOT_EVENT_SEND[*]}" != "" ] && event_send "upload" "$@" &
} }
else else
# simple curl or wget call outputs result to stdout # simple curl or wget call outputs result to stdout
@ -273,12 +273,12 @@ else
--header='Content-Type:application/json' "${3}" | "${JSONSHFILE}" -s -b -n )" --header='Content-Type:application/json' "${3}" | "${JSONSHFILE}" -s -b -n )"
BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "$res")" BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "$res")"
BOTSENT[ID]="$(JsonGetValue '"result","message_id"' <<< "$res")" BOTSENT[ID]="$(JsonGetValue '"result","message_id"' <<< "$res")"
[ "${BASHBOT_EVENT_SEND[*]}" != "" ] && event_send "send" "$@" & [ "${SOURCE}" != "yes" ] && [ "${BASHBOT_EVENT_SEND[*]}" != "" ] && event_send "send" "$@" &
} }
sendUpload() { sendUpload() {
sendJson "$1" '"text":"Sorry, wget does not support file upload"' "${MSG_URL}" sendJson "$1" '"text":"Sorry, wget does not support file upload"' "${MSG_URL}"
BOTSENT[OK]="false" BOTSENT[OK]="false"
[ "${BASHBOT_EVENT_SEND[*]}" != "" ] && event_send "upload" "$@" & [ "${SOURCE}" != "yes" ] && [ "${BASHBOT_EVENT_SEND[*]}" != "" ] && event_send "upload" "$@" &
} }
fi fi