From 279a9e7ca3916f001c43a1c2f0b0e0c74d0e367d Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Wed, 27 Jan 2021 19:05:12 +0100 Subject: [PATCH] doc: add iBUTTON variables --- bashbot.sh | 6 ++---- doc/2_usage.md | 35 ++++++++++++++++++++++++++++------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index d930f2d..e48be1a 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -30,7 +30,7 @@ BOTCOMMANDS="-h help init start stop status suspendback resumeback killb # 8 - curl/wget missing # 10 - not bash! # -#### $$VERSION$$ v1.35-dev-30-ge83f4d4 +#### $$VERSION$$ v1.35-dev-31-ga3eec98 ################################################################## # emmbeded system may claim bash but it is not @@ -870,11 +870,9 @@ process_inline_button() { # debugging for impelemetation local num="$1" iBUTTON[DATA]="${UPD["result,${num},callback_query,data"]}" - #iBUTTON[CHAT_INSTANCE]="${UPD["result,${num},callback_query,chat_instance"]}" - #iBUTTON[INLINE_ID]="${UPD["result,${num},callback_query,inline_message_id"]}" iBUTTON[CHAT_ID]="${UPD["result,${num},callback_query,message,chat,id"]}" iBUTTON[MESSAGE_ID]="${UPD["result,${num},callback_query,message,message_id"]}" - iBUTTON[MEESSAGE]="$(JsonDecode "${UPD["result,${num},callback_query,message,text"]}")" + iBUTTON[MESSAGE]="$(JsonDecode "${UPD["result,${num},callback_query,message,text"]}")" # XXX should we give back pressed button, all buttons or nothing? iBUTTON[USER_ID]="${UPD["result,${num},callback_query,from,id"]}" iBUTTON[FIRST_NAME]="$(JsonDecode "${UPD["result,${num},callback_query,from,first_name"]}")" diff --git a/doc/2_usage.md b/doc/2_usage.md index 6ec08bf..767d6d3 100644 --- a/doc/2_usage.md +++ b/doc/2_usage.md @@ -33,14 +33,19 @@ Have FUN! ├── JSON.sh # bashbots JSON parser, see https://github.com/dominictarr/JSON.sh │ ├── bin # ready to use scripts, use `scriptname --help` for help +│   ├── bashbot_stats.sh # does what it says ... +│   ├── send_broadcast.sh # send message to all known chats │   ├── send_message.sh # send message to given chat │   ├── edit_message.sh # replace given message id in given chat -│   ├── delete_message.sh # delete given message id in given chat -│   ├── send_broadcast.sh # send message to all known chats │   ├── send_file.sh # send file to given chat -│   ├── bashbot_stats.sh # does what it says ... +│   ├── delete_message.sh # delete given message id in given chat +│   ├── send_buttons.sh # send message with attached button +│   ├── edit_buttons.sh # attach/edit message buttons +│   ├── kickban_user.sh # kick/unban user from given chat +│   ├── promote_user.sh # promote/dente user rights in given chat │ │ -│   └── bashbot_env.inc.sh # bashbot location included from scripts, adapt if needed +│   └── bashbot_env.inc.sh # sourced from scripts, adapt locations if needed +│   └── bashbot_init.inc.sh # sourced from bashbot.sh init │ ├── scripts # place your bashbot interactive and background scripts here │   └── interactive.sh.clean # interactive script template for new scripts @@ -91,6 +96,7 @@ Start or Stop your Bot use the following commands: ``` ### Scripts in bin/ +Use `script.sh -h` or `script --help` to get short/long help for script. To count the total number of users and messages run the following command: @@ -244,8 +250,7 @@ e.g. if a new user joins a chat MESSAGE is set to "/_new_chat_user". ### Inline query messages - -Inline query messages are small, non regular messages used for interaction with the user, +Inline query messages are special messages used for interaction with the user, they contain the following variables only: * `${iQUERY}`: Current inline query @@ -256,6 +261,22 @@ they contain the following variables only: * `${iQUERY[LAST_NAME]}`: User's last name +### Callback button messages +Callback button messages special messages swedn from callback buttons, +they contain the following variables only: + +* `$iBUTTON`: This array contains the ID, First name, last name, username and user id of the user clicked on the button + * `${iBUTTON[ID]}`: Callback query ID + * `${iBUTTON[DATA]`: Data attached to button, hopefully unique + * `${iBUTTON[CHAT_ID]`: Chat where button was pressed + * `${iBUTTON[MESSAGE_ID]`: Message to which button is attached + * `${iBUTTON[MESSAGE]`: Text of message + * `${iBUTTON[USER_ID]}`: User's id + * `${iBUTTON[FIRST_NAME]}`: User's first name + * `${iBUTTON[LAST_NAME]}`: User's last name + * `${iBUTTON[USERNAME]}`: User's @username + + ## Send data / get response After every `send_xxx` `get_xxx` call the array BOTSENT contains the most important values from Telegram response. @@ -351,5 +372,5 @@ send_action "${CHAT[ID]}" "action" #### [Prev Create Bot](1_firstbot.md) #### [Next Advanced Usage](3_advanced.md) -#### $$VERSION$$ v1.30-0-g3266427 +#### $$VERSION$$ v1.35-dev-31-ga3eec98