mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2025-01-15 02:13:44 +00:00
modules: sendMessage: more comforable inline_buttons functions
This commit is contained in:
parent
e4ee88003e
commit
75e775606a
@ -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.35-dev-16-g2222875
|
#### $$VERSION$$ v1.35-dev-18-ge4ee880
|
||||||
|
|
||||||
# will be automatically sourced from bashbot
|
# will be automatically sourced from bashbot
|
||||||
|
|
||||||
@ -137,18 +137,18 @@ remove_keyboard() {
|
|||||||
#JSON='"text":"$2", "reply_markup": {"remove_keyboard":true}'
|
#JSON='"text":"$2", "reply_markup": {"remove_keyboard":true}'
|
||||||
}
|
}
|
||||||
|
|
||||||
# $1 CHAT $2 message-id $3 keyboard
|
# buttons will specified as "texts
|
||||||
edit_inline_keyboard() {
|
#|url" ... "text|url" empty arg starts new row
|
||||||
sendJson "$1" '"message_id":'"$2"', "reply_markup": {"inline_keyboard": [ '"$3"' ]}' "${URL}/editMessageReplyMarkup"
|
# url not starting with http:// or https:// will be send as callback_data
|
||||||
# JSON='"message_id":"$2", "reply_markup": {"inline_keyboard": [ $3->[{"text":"text", "url":"url"}]<- ]}'
|
send_inline_buttons(){
|
||||||
|
send_inline_keyboard "$1" "$2" "$(_button_row "${@:3}")"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# $1 CHAT $2 message-id $3 buttons
|
||||||
# $1 CHAT $2 message $3 keyboard
|
# buttons will specified as "text|url" ... "text|url" empty arg starts new row
|
||||||
send_inline_keyboard() {
|
# url not starting with http:// or https:// will be send as callback_data
|
||||||
local text; text='"text":"'$(JsonEscape "$2")'"'; [ -z "$2" ] && text='"text":"..."'
|
edit_inline_buttons(){
|
||||||
sendJson "$1" "${text}"', "reply_markup": {"inline_keyboard": [ '"$3"' ]}' "${MSG_URL}"
|
edit_inline_keyboard "$1" "$2" "$(_button_row "${@:3}")"
|
||||||
# JSON='"text":"$2", "reply_markup": {"inline_keyboard": [ $3->[{"text":"text", "url":"url"}]<- ]}'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -174,6 +174,21 @@ _button_row() {
|
|||||||
printf "[%s]" "${json}"
|
printf "[%s]" "${json}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# raw inline functions, for special use
|
||||||
|
# $1 CHAT $2 message-id $3 keyboard
|
||||||
|
edit_inline_keyboard() {
|
||||||
|
sendJson "$1" '"message_id":'"$2"', "reply_markup": {"inline_keyboard": [ '"$3"' ]}' "${URL}/editMessageReplyMarkup"
|
||||||
|
# JSON='"message_id":"$2", "reply_markup": {"inline_keyboard": [ $3->[{"text":"text", "url":"url"}]<- ]}'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# $1 CHAT $2 message $3 keyboard
|
||||||
|
send_inline_keyboard() {
|
||||||
|
local text; text='"text":"'$(JsonEscape "$2")'"'; [ -z "$2" ] && text='"text":"..."'
|
||||||
|
sendJson "$1" "${text}"', "reply_markup": {"inline_keyboard": [ '"$3"' ]}' "${MSG_URL}"
|
||||||
|
# JSON='"text":"$2", "reply_markup": {"inline_keyboard": [ $3->[{"text":"text", "url":"url"}]<- ]}'
|
||||||
|
}
|
||||||
|
|
||||||
# $1 callback id, $2 text to show, alert if not empty
|
# $1 callback id, $2 text to show, alert if not empty
|
||||||
answer_callback_query() {
|
answer_callback_query() {
|
||||||
local alert
|
local alert
|
||||||
|
Loading…
Reference in New Issue
Block a user