From b096338c3342bfe76678c27761481ef0c4af86d1 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Tue, 26 Jan 2021 14:51:50 +0100 Subject: [PATCH] doc: add answer_callback_query --- doc/6_reference.md | 15 ++++++++++++++- modules/sendMessage.sh | 4 ++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/doc/6_reference.md b/doc/6_reference.md index 6b162e2..37392e9 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -289,6 +289,7 @@ In both cases the message itself is not changed, only the attached inline keyboa To create a JSON button array I suggest to use `_button_row`. +*example:* ```bash # message without button send_markdownv2_message "${CHAT[ID]}" "*HI* this is a _markdown_ message ..." @@ -306,6 +307,18 @@ edit_markdownv2_message "${CHAT[ID]}" "*HI* this is a _markdown_ message inline ``` +##### answer_callback_query +Each request send from a callback button must be answered by a call to `answer_callback_query`. +If alert is given an alert will be shown by the Telegram client instead of a notification. + +*usage:* answer_callback_query "iBUTTON[ID]" "text notification ..." ["alert"] + +*example:* +```bash +answer_callback_query "${iBUTTON[ID]}" "Button data is: ${iBUTTON[DATA]}" + +answer_callback_query "${iBUTTON[ID]}" "Alert: Button pressed!" "alert" +``` ---- @@ -1342,5 +1355,5 @@ The name of your bot is available as bash variable "$ME", there is no need to ca #### [Prev Best Practice](5_practice.md) #### [Next Notes for Developers](7_develop.md) -#### $$VERSION$$ v1.35-dev-10-g70a3c19 +#### $$VERSION$$ v1.35-dev-16-g2222875 diff --git a/modules/sendMessage.sh b/modules/sendMessage.sh index 774cdbb..115cbe2 100644 --- a/modules/sendMessage.sh +++ b/modules/sendMessage.sh @@ -6,7 +6,7 @@ # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # # shellcheck disable=SC1117 -#### $$VERSION$$ v1.35-dev-15-gb441384 +#### $$VERSION$$ v1.35-dev-16-g2222875 # will be automatically sourced from bashbot @@ -174,7 +174,7 @@ _button_row() { printf "[%s]" "${json}" } -# $1 callback id, $2 test to show, alert if not empty +# $1 callback id, $2 text to show, alert if not empty answer_callback_query() { local alert [ -n "$3" ] && alert='","show_alert": true'