From d11598e0829f713a2f84cd4473b24c2395735e34 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sun, 7 Jun 2020 19:06:02 +0200 Subject: [PATCH] make curl location configurable --- bashbot.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index 7701d8a..d42e672 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -11,7 +11,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.96-dev3-12-g3f85134 +#### $$VERSION$$ v0.96-dev3-15-g3fcb854 # # Exit Codes: # - 0 sucess (hopefully) @@ -306,17 +306,19 @@ TIMEOUT="${BASHBOT_TIMEOUT}" [[ "$TIMEOUT" =~ ^[0-9]+$ ]] || TIMEOUT="20" if [ -z "${BASHBOT_WGET}" ] && _exists curl ; then + [ -z "${BASHBOT_CURL}" ] && BASHBOT_CURL="curl" # simple curl or wget call, output to stdout getJson(){ # shellcheck disable=SC2086 - curl -sL -k ${BASHBOT_CURL_ARGS} -m "${TIMEOUT}" "$1" + "${BASHBOT_CURL}" -sL -k ${BASHBOT_CURL_ARGS} -m "${TIMEOUT}" "$1" } # usage: sendJson "chat" "JSON" "URL" sendJson(){ local chat=""; [ -n "${1}" ] && chat='"chat_id":'"${1}"',' # shellcheck disable=SC2086 - res="$(curl -s -k ${BASHBOT_CURL_ARGS} -m "${TIMEOUT}" -d '{'"${chat} $(iconv -f utf-8 -t utf-8 -c <<<$2)"'}' -X POST "${3}" \ + res="$("${BASHBOT_CURL}" -s -k ${BASHBOT_CURL_ARGS} -m "${TIMEOUT}"\ + -d '{'"${chat} $(iconv -f utf-8 -t utf-8 -c <<<$2)"'}' -X POST "${3}" \ -H "Content-Type: application/json" | "${JSONSHFILE}" -s -b -n )" BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "${res}")" BOTSENT[ID]="$(JsonGetValue '"result","message_id"' <<< "${res}")" @@ -329,10 +331,12 @@ if [ -z "${BASHBOT_WGET}" ] && _exists curl ; then [ "$#" -lt 4 ] && return if [ -n "$5" ]; then # shellcheck disable=SC2086 - res="$(curl -s -k ${BASHBOT_CURL_ARGS} "$4" -F "chat_id=$1" -F "$2=@$3;${3##*/}" -F "caption=$5" | "${JSONSHFILE}" -s -b -n )" + res="$("${BASHBOT_CURL}" -s -k ${BASHBOT_CURL_ARGS} "$4" -F "chat_id=$1"\ + -F "$2=@$3;${3##*/}" -F "caption=$5" | "${JSONSHFILE}" -s -b -n )" else # shellcheck disable=SC2086 - res="$(curl -s -k ${BASHBOT_CURL_ARGS} "$4" -F "chat_id=$1" -F "$2=@$3;${3##*/}" | "${JSONSHFILE}" -s -b -n )" + res="$("${BASHBOT_CURL}" -s -k ${BASHBOT_CURL_ARGS} "$4" -F "chat_id=$1"\ + -F "$2=@$3;${3##*/}" | "${JSONSHFILE}" -s -b -n )" fi BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "${res}")" [ "${SOURCE}" != "yes" ] && [ -n "${BASHBOT_EVENT_SEND[*]}" ] && event_send "upload" "$@" &