From 8f4b1688bdbb05a449afc550cb98c0a5e4763203 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Thu, 25 Apr 2019 15:39:42 +0200 Subject: [PATCH] more conversion to sendJson --- bashbot.sh | 15 +++++++-------- dev/git-add.sh | 13 +++++++++++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index 525598b..1db0d08 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -12,7 +12,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.70-dev3-1-g55dab95 +#### $$VERSION$$ v0.70-dev3-3-g0f220bd # # Exit Codes: # - 0 sucess (hopefully) @@ -188,24 +188,25 @@ send_html_message() { } delete_message() { - res="$(curl -s "$DELETE_URL" -F "chat_id=$1" -F "message_id=$2")" + sendJson "$1" 'message_id: '"$2"'' "$DELETE_URL" } # usage: status="$(get_chat_member_status "chat" "user")" get_chat_member_status() { - curl -s "$GETMEMBER_URL" -F "chat_id=$1" -F "user_id=$2" | "${JSONSHFILE}" -s -b -n | sed -n -e '/\["result","status"\]/ s/.*\][ \t]"\(.*\)"$/\1/p' + sendJson "$1" 'user_id: '"$2"'' "$GETMEMBER_URL" + echo "$res" | JsonGetString '"result","status"' } kick_chat_member() { - res="$(curl -s "$KICK_URL" -F "chat_id=$1" -F "user_id=$2")" + sendJson "$1" 'user_id: '"$2"'' "$KICK_URL" } unban_chat_member() { - res="$(curl -s "$UNBAN_URL" -F "chat_id=$1" -F "user_id=$2")" + sendJson "$1" 'user_id: '"$2"'' "$UNBAN_URL" } leave_chat() { - res="$(curl -s "$LEAVE_URL" -F "chat_id=$1")" + sendJson "$1" "" "$LEAVE_URL" } user_is_creator() { @@ -347,10 +348,8 @@ send_inline_keyboard() { } send_inline_button() { send_inline_keyboard "${1}" "${2}" '[ {"text":"'"${3}"'", "url":"'"${4}"'"}]' - # JSON='"text":"$2", "reply_markup": {"inline_keyboard": [[ {"text":"$3", "url":"$4"} ... ]]}' } -# this will be the only send interface to telegram! # usage: sendJson "chat" "JSON" "URL" sendJson(){ res="$(curl -d '{"chat_id":'"${1}"', '"$2"'}' -H "Content-Type: application/json" \ diff --git a/dev/git-add.sh b/dev/git-add.sh index 1073334..9385ef5 100755 --- a/dev/git-add.sh +++ b/dev/git-add.sh @@ -3,7 +3,7 @@ # # works together with git pre-push.sh and ADD all changed files since last push -#### $$VERSION$$ v0.70-dev3-1-g55dab95 +#### $$VERSION$$ v0.70-dev3-3-g0f220bd # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script @@ -13,8 +13,17 @@ cd "$GIT_DIR/.." || exit 1 FILES="$(find ./* -newer .git/.lastpush)" [ "${FILES}" = "" ] && echo "Noting changed since last push!" && exit +# run pre_commit on files +dev/hooks/pre-commit.sh + +echo -n "Add files to repo: " # shellcheck disable=SC2086 -echo Add ${FILES} to repo ... +for file in ${FILES} +do + [ -d "${file}" ] && continue + git add "${file}" && echo -n "${file} " +done +echo "done." # shellcheck disable=SC2086 git add ${FILES}