mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-12-28 12:50:44 +00:00
modules: helper function _button_row
This commit is contained in:
parent
f2dd64c900
commit
e923e2e8fc
@ -6,7 +6,7 @@
|
|||||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||||
#
|
#
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
#### $$VERSION$$ v1.31-dev-5-gf66e570
|
#### $$VERSION$$ v1.31-dev-6-gf2dd64c
|
||||||
|
|
||||||
# will be automatically sourced from bashbot
|
# will be automatically sourced from bashbot
|
||||||
|
|
||||||
@ -145,11 +145,24 @@ send_inline_keyboard() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# $1 CHAT $2 message $3 button text $4 URL
|
# $1 CHAT $2 message $3 button text
|
||||||
send_button() {
|
send_button() {
|
||||||
send_inline_keyboard "$1" "$2" '[{"text":"'"$3"'", "url":"'"$4"'"}]'
|
send_inline_keyboard "$1" "$2" '[{"text":"'"$3"'", "url":"'"$4"'"}]'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# helper function to create json for a button row
|
||||||
|
# buttons will specified as "text|url" ... "text|url"
|
||||||
|
_button_row() {
|
||||||
|
[ -z "$1" ] && return 1
|
||||||
|
local arg json
|
||||||
|
for arg in "$@"
|
||||||
|
do
|
||||||
|
[ -n "${json}" ] && json+=","
|
||||||
|
json+='{"text":"'"${arg%|*}"'", "url":"'"${arg##*|}"'"}'
|
||||||
|
done
|
||||||
|
printf "[%s]" "${json}"
|
||||||
|
}
|
||||||
|
|
||||||
# $1 chat, $2 file_id on telegram server
|
# $1 chat, $2 file_id on telegram server
|
||||||
send_sticker() {
|
send_sticker() {
|
||||||
sendJson "$1" '"sticker": "'"$2"'"' "${URL}/sendSticker"
|
sendJson "$1" '"sticker": "'"$2"'"' "${URL}/sendSticker"
|
||||||
|
Loading…
Reference in New Issue
Block a user