mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2025-01-23 13:48:24 +00:00
more conversion to sendJson
This commit is contained in:
parent
0f220bdbc8
commit
8f4b1688bd
15
bashbot.sh
15
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" \
|
||||
|
@ -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}
|
||||
|
Loading…
x
Reference in New Issue
Block a user