From 9b850002ef8fcf324c279de500ae5500a9befd5c Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Thu, 9 May 2019 14:49:23 +0200 Subject: [PATCH] prepare for 0.72 release with working inline query --- README.html | 2 +- README.md | 2 +- README.txt | 2 +- bashbot.rc | 2 +- bashbot.sh | 2 +- commands.sh | 2 +- dev/all-tests.sh | 2 +- dev/git-add.sh | 2 +- dev/hooks/pre-commit.sh | 2 +- dev/hooks/pre-push.sh | 2 +- dev/install-hooks.sh | 2 +- dev/make-dist.sh | 2 +- dev/shellcheck.files | 2 +- dev/version.sh | 2 +- doc/0_install.md | 2 +- doc/1_firstbot.md | 2 +- doc/2_usage.md | 2 +- doc/3_advanced.md | 2 +- doc/4_expert.md | 2 +- doc/5_practice.md | 2 +- doc/6_reference.md | 95 +++++++++++--- doc/7_develop.md | 2 +- doc/8_custom.md | 2 +- examples/README.md | 2 +- examples/background-scripts/run_diskusage.sh | 2 +- .../background-scripts/run_filecontent.sh | 2 +- examples/background-scripts/run_filename.sh | 2 +- examples/background-scripts/run_notify.sh | 2 +- examples/bashbot-multi.sh | 2 +- examples/bashbot.cron | 2 +- examples/calc.sh | 2 +- examples/notify.sh | 2 +- examples/question.sh | 2 +- examples/send-system-status/botacl | 2 +- examples/send-system-status/mycommands.sh | 2 +- modules/aliases.sh | 2 +- modules/background.sh | 2 +- modules/inline.sh | 118 +++++++++++------- mycommands.sh | 2 +- test/ADD-test-new.sh | 2 +- test/ALL-tests.inc.sh | 2 +- test/a-commit-test.sh | 2 +- test/b-example-test.sh | 2 +- test/c-init-test.sh | 2 +- test/d-JSON.sh-test.sh | 2 +- test/d-process_inline-test.sh | 2 +- test/d-process_message-test.sh | 2 +- test/d-send_message-test.sh | 2 +- test/d-user_is-test.sh | 2 +- test/e-env-test.sh | 2 +- 50 files changed, 204 insertions(+), 105 deletions(-) diff --git a/README.html b/README.html index 3312bf0..f00529e 100644 --- a/README.html +++ b/README.html @@ -97,6 +97,6 @@

@Gnadelwartz

That’s it!

If you feel that there’s something missing or if you found a bug, feel free to submit a pull request!

-


VERSION
v0.80-dev-2-g4e4194d

+


VERSION
v0.72-dev-0-g6afa177

diff --git a/README.md b/README.md index d28a216..309fdc5 100644 --- a/README.md +++ b/README.md @@ -94,4 +94,4 @@ Well, thats a damn good question ... may be because I'm an Unix/Linux admin from If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 diff --git a/README.txt b/README.txt index 0640296..cc0cf52 100644 --- a/README.txt +++ b/README.txt @@ -133,4 +133,4 @@ health status If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 diff --git a/bashbot.rc b/bashbot.rc index ca40b84..fb73bb1 100755 --- a/bashbot.rc +++ b/bashbot.rc @@ -1,7 +1,7 @@ #!/bin/sh # description: Start or stop telegram-bash-bot # -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # shellcheck disable=SC2009 # shellcheck disable=SC2181 diff --git a/bashbot.sh b/bashbot.sh index d6e232e..819b69d 100755 --- a/bashbot.sh +++ b/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-9-g2557ea7 +#### $$VERSION$$ v0.72-dev-0-g6afa177 # # Exit Codes: # - 0 sucess (hopefully) diff --git a/commands.sh b/commands.sh index 061fc61..2c8838d 100644 --- a/commands.sh +++ b/commands.sh @@ -5,7 +5,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-10-gcbdfc7c +#### $$VERSION$$ v0.72-dev-0-g6afa177 # # shellcheck disable=SC2154 # shellcheck disable=SC2034 diff --git a/dev/all-tests.sh b/dev/all-tests.sh index 0a5683c..c128f8b 100755 --- a/dev/all-tests.sh +++ b/dev/all-tests.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # this has to run once atfer git clone # and every time we create new hooks -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script diff --git a/dev/git-add.sh b/dev/git-add.sh index b4d1b9c..6774ea6 100755 --- a/dev/git-add.sh +++ b/dev/git-add.sh @@ -3,7 +3,7 @@ # # works together with git pre-push.sh and ADD all changed files since last push -#### $$VERSION$$ v0.80-dev-3-g9bcab66 +#### $$VERSION$$ v0.72-dev-0-g6afa177 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script diff --git a/dev/hooks/pre-commit.sh b/dev/hooks/pre-commit.sh index 25246ee..e534919 100755 --- a/dev/hooks/pre-commit.sh +++ b/dev/hooks/pre-commit.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 ############ # NOTE: you MUST run install-hooks.sh again when updating this file! diff --git a/dev/hooks/pre-push.sh b/dev/hooks/pre-push.sh index 22d70da..fb21143 100755 --- a/dev/hooks/pre-push.sh +++ b/dev/hooks/pre-push.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 ############ # NOTE: you MUST run install-hooks.sh again when updating this file! diff --git a/dev/install-hooks.sh b/dev/install-hooks.sh index 858a9b4..de89a65 100755 --- a/dev/install-hooks.sh +++ b/dev/install-hooks.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # this has to run once atfer git clone # and every time we create new hooks -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script diff --git a/dev/make-dist.sh b/dev/make-dist.sh index 0d46df1..8efb648 100755 --- a/dev/make-dist.sh +++ b/dev/make-dist.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # this has to run once atfer git clone # and every time we create new hooks -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script diff --git a/dev/shellcheck.files b/dev/shellcheck.files index 7aa707b..70914ab 100644 --- a/dev/shellcheck.files +++ b/dev/shellcheck.files @@ -1,3 +1,3 @@ # list of additional files to check from shellcheck -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 bashbot.rc diff --git a/dev/version.sh b/dev/version.sh index 55f0acf..4007ef4 100755 --- a/dev/version.sh +++ b/dev/version.sh @@ -1,6 +1,6 @@ #!/bin/bash # -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # shellcheck disable=SC2016 # # Easy Versioning in git: diff --git a/doc/0_install.md b/doc/0_install.md index b26b30f..b83352e 100644 --- a/doc/0_install.md +++ b/doc/0_install.md @@ -63,5 +63,5 @@ The old format is supported for backward compatibility, but may fail for corner #### [Next Create Bot](1_firstbot.md) -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 diff --git a/doc/1_firstbot.md b/doc/1_firstbot.md index 25dcbb2..78bffb5 100644 --- a/doc/1_firstbot.md +++ b/doc/1_firstbot.md @@ -65,5 +65,5 @@ group. This step is up to you actually. #### [Prev Installation](0_install.md) #### [Next Getting started](2_usage.md) -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 diff --git a/doc/2_usage.md b/doc/2_usage.md index cd04160..70210bf 100644 --- a/doc/2_usage.md +++ b/doc/2_usage.md @@ -179,5 +179,5 @@ send_action "${CHAT[ID]}" "action" #### [Prev Create Bot](1_firstbot.md) #### [Next Advanced Usage](3_advanced.md) -#### $$VERSION$$ v0.80-dev-3-g9bcab66 +#### $$VERSION$$ v0.72-dev-0-g6afa177 diff --git a/doc/3_advanced.md b/doc/3_advanced.md index 11c6620..8386b9f 100644 --- a/doc/3_advanced.md +++ b/doc/3_advanced.md @@ -178,5 +178,5 @@ answer_inline_query "${iQUERY[ID]}" "cached_sticker" "identifier for the sticker #### [Prev Getting started](2_usage.md) #### [Next Expert Use](4_expert.md) -#### $$VERSION$$ v0.80-dev-3-g9bcab66 +#### $$VERSION$$ v0.72-dev-0-g6afa177 diff --git a/doc/4_expert.md b/doc/4_expert.md index c74cead..8d435c8 100644 --- a/doc/4_expert.md +++ b/doc/4_expert.md @@ -104,5 +104,5 @@ An example crontab is provided in ```examples/bashbot.cron```. #### [Prev Expert Use](4_expert.md) #### [Next Best Practice](5_practice.md) -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 diff --git a/doc/5_practice.md b/doc/5_practice.md index efd75e5..a8defac 100644 --- a/doc/5_practice.md +++ b/doc/5_practice.md @@ -153,5 +153,5 @@ The second warning is about an unused variable, this is true because in our exam #### [Prev Best Practice](5_practice.md) #### [Next Functions Reference](6_reference.md) -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 diff --git a/doc/6_reference.md b/doc/6_reference.md index d460641..e04e764 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -72,16 +72,6 @@ See also [deleteMessage limitations](https://core.telegram.org/bots/api#deleteme ---- -##### answer_inline_query -Inline Queries allows users to interact with your bot directly without sending extra commands. -answer_inline_query provide the result to a users Inline Query - -*usage:* answer_inline_query "$iQUERY_ID" "type" "type arg 1" ... "type arg n" - -*example:* - see [Advanced Usage](3_advanced.md#Inline-queries) - ----- - ### File, Location, Venue, Keyboard @@ -251,8 +241,85 @@ fi ---- +### Inline Queries - answer direct queries to bot +You must include ```source modules/inline.sh``` in 'commands.sh' to have the following functions availible. + +Inline Queries allows users to interact with your bot directly without sending extra commands. +As an aswer to an inline query you can send back one or more results to the client. The Client +will show the results to the user and let him selcet one. + +##### answer_inline_query +answer_inline_query is provided for backward compatibility with older versions of bashbot. +It send back only one response to an inline query. + +*usage:* answer_inline_query "$i{QUERY[ID]}" "type" "type arg 1" ... "type arg n" + +*example:* - see [Advanced Usage](3_advanced.md#Inline-queries) + +---- + + +##### answer_inline_multi +anser_inline_multi allows you to send back a list of responses. responses must be seperated by ','. + +*usage:* answer_inline_multi "${iQUERY[ID]}" "res, res, ... res" + +*example:* +```bash +# note the starting " and ending " !! +answer_inline_multi "${iQUERY[ID]}" " + $(inline_query_compose "1" "photo" "https://avatars0.githubusercontent.com/u/13046303") , + ... + $(inline_query_compose "n" "photo" "https://avatars1.githubusercontent.com/u/4593242") + " +``` + +---- + +#### inline_query_compose +inline_query_compose composes one response element to to send back. + +*usage:* inline_query_compose ID type args .... + +``` + ID = unique ID for answer + type = type of answer, e.g. article, photo, video, localtion ... + args = arguments in the order as described in telegram doc, mandatory first, them optional +``` +see [InlineQueryResult for more information](https://core.telegram.org/bots/api#inlinequeryresult) + + +Currently the following types and args are implemented (optional args in parenthesis) +``` + "article"|"message" title message (markup decription) + + "photo" photo_URL (thumb_URL title description caption) + "gif" photo_URL (thumb_URL title caption) + "mpeg4_gif" mpeg_URL (thumb_URL title caption) + "video" video_URL mime_type thumb_URL title (caption) + "audio" audio_URL title (caption) + "voice" voice_URL title (caption) + "document" title document_URL mime_type (caption description) + + "location" latitude longitude title + "venue" latitude longitude title (adress foursquare) + "contact" phone first (last thumb) + + "cached_photo" file (title description caption) + "cached_gif" file (title caption) + "cached_mpeg4_gif" file (title caption) + "cached_sticker" file + "cached_document" title file (description caption) + "cached_video" file title (description caption) + "cached_voice" file title (caption) + "cached_audio" file title (caption) +``` + +---- + + ### Aliases - shortcuts for often used funtions -You must not disable ```source modules/aliases.sh``` in 'commands.sh' to have the following functions availible. +You must include ```source modules/aliases.sh``` in 'commands.sh' to have the following functions availible. ##### _is_botadmin @@ -320,8 +387,8 @@ You must not disable ```source modules/aliases.sh``` in 'commands.sh' to have t ---- -### Interactive and backgound jobs -You must not disable ```source modules/background.sh``` in 'commands.sh' to have the following functions availible. +### Background and Interactive jobs +You must include ```source modules/background.sh``` in 'commands.sh' to have the following functions availible. ##### startproc ```startproc``` starts a script, the output of the script is sent to the user or chat, user input will be sent back to the script. see [Advanced Usage](3_advanced.md#Interactive-Chats) @@ -489,5 +556,5 @@ Send Input from Telegram to waiting Interactive Chat. #### [Prev Best Practice](5_practice.md) #### [Next Notes for Developers](7_develop.md) -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 diff --git a/doc/7_develop.md b/doc/7_develop.md index 7f6b51d..3d2c88e 100644 --- a/doc/7_develop.md +++ b/doc/7_develop.md @@ -117,5 +117,5 @@ fi #### [Prev Function Reference](6_reference.md) #### [Next Bashbot Environment](8_custom.md) -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 diff --git a/doc/8_custom.md b/doc/8_custom.md index 13abb6b..372c078 100644 --- a/doc/8_custom.md +++ b/doc/8_custom.md @@ -117,5 +117,5 @@ for every poll until the maximum of BASHBOT_SLEEP ms. #### [Prev Notes for Developers](7_develop.md) -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 diff --git a/examples/README.md b/examples/README.md index 98416ba..15b994b 100644 --- a/examples/README.md +++ b/examples/README.md @@ -55,6 +55,6 @@ convert existing bots. **external-use** will contain some examples on how to send messages from external scripts to Telegram chats or users. -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 diff --git a/examples/background-scripts/run_diskusage.sh b/examples/background-scripts/run_diskusage.sh index 88adf60..adfe58b 100755 --- a/examples/background-scripts/run_diskusage.sh +++ b/examples/background-scripts/run_diskusage.sh @@ -4,7 +4,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.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/background-scripts/run_filecontent.sh b/examples/background-scripts/run_filecontent.sh index c1fa5d2..1c5f555 100755 --- a/examples/background-scripts/run_filecontent.sh +++ b/examples/background-scripts/run_filecontent.sh @@ -2,7 +2,7 @@ # file: run_filename # background job to display content of all new files in WATCHDIR # -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/background-scripts/run_filename.sh b/examples/background-scripts/run_filename.sh index 27dd236..cb10828 100755 --- a/examples/background-scripts/run_filename.sh +++ b/examples/background-scripts/run_filename.sh @@ -2,7 +2,7 @@ # file: run_filename # background job to display all new files in WATCHDIR # -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/background-scripts/run_notify.sh b/examples/background-scripts/run_notify.sh index 2c6c056..66a6dfd 100755 --- a/examples/background-scripts/run_notify.sh +++ b/examples/background-scripts/run_notify.sh @@ -4,7 +4,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.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/bashbot-multi.sh b/examples/bashbot-multi.sh index 26582b0..8a10153 100755 --- a/examples/bashbot-multi.sh +++ b/examples/bashbot-multi.sh @@ -2,7 +2,7 @@ # file. multibot.sh # description: run multiple telegram bots from one installation # -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then echo "Usage: $0 botname command" diff --git a/examples/bashbot.cron b/examples/bashbot.cron index 2e095ab..87cb36b 100644 --- a/examples/bashbot.cron +++ b/examples/bashbot.cron @@ -7,7 +7,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.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 SHELL=/bin/sh diff --git a/examples/calc.sh b/examples/calc.sh index a63f054..d89c382 100755 --- a/examples/calc.sh +++ b/examples/calc.sh @@ -5,7 +5,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.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/notify.sh b/examples/notify.sh index 2c6c056..66a6dfd 100755 --- a/examples/notify.sh +++ b/examples/notify.sh @@ -4,7 +4,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.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/question.sh b/examples/question.sh index 6d9e382..b883955 100755 --- a/examples/question.sh +++ b/examples/question.sh @@ -5,7 +5,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.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/send-system-status/botacl b/examples/send-system-status/botacl index b61c6e9..681a05b 100644 --- a/examples/send-system-status/botacl +++ b/examples/send-system-status/botacl @@ -1,7 +1,7 @@ # file: botacl # a user not listed here, will return false from 'user_is_allowed' # -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # Format: # user:ressource:chat diff --git a/examples/send-system-status/mycommands.sh b/examples/send-system-status/mycommands.sh index 1bc0e8e..c3073f7 100644 --- a/examples/send-system-status/mycommands.sh +++ b/examples/send-system-status/mycommands.sh @@ -5,7 +5,7 @@ # to show how you can customize bashbot by only editing mycommands.sh # NOTE: this is not tested, simply copied from original source and reworked! # -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # # shellcheck disable=SC2154 # shellcheck disable=SC2034 diff --git a/modules/aliases.sh b/modules/aliases.sh index 128ae5e..e738984 100644 --- a/modules/aliases.sh +++ b/modules/aliases.sh @@ -5,7 +5,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-7-g66c390e +#### $$VERSION$$ v0.72-dev-0-g6afa177 # # source from commands.sh to use the aliases diff --git a/modules/background.sh b/modules/background.sh index 73622c4..8c4818f 100644 --- a/modules/background.sh +++ b/modules/background.sh @@ -5,7 +5,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.80-dev-3-g9bcab66 +#### $$VERSION$$ v0.72-dev-0-g6afa177 # source from commands.sh if you want ro use interactive or background jobs diff --git a/modules/inline.sh b/modules/inline.sh index 6884a04..da1b7d2 100644 --- a/modules/inline.sh +++ b/modules/inline.sh @@ -5,7 +5,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-10-gcbdfc7c +#### $$VERSION$$ v0.72-dev-0-g6afa177 # source from commands.sh to use the inline functions @@ -31,74 +31,106 @@ answer_inline_multi() { } # $1 unique ID for answer -# remaining arguments are in the order as shown in telegram doc: https://core.telegram.org/bots/api#inlinequeryresult +# $2 type of answer +# remaining arguments are the "must have" arguments in the order as in telegram doc +# followed by the optional arguments: https://core.telegram.org/bots/api#inlinequeryresult inline_query_compose(){ local JSON="{}" local ID="${1}" + local title markup caption fours last desc case "${2}" in # user provided media - "article") - local parse=',"parse_mode":'"${5}" && [ "${5}" = "" ] && parse="" - JSON='{"type":"article","id":"'$ID'","title":"'$3'","message_text":"'$4'"'"${parse}"'}' + "article"|"message") # article ID title message (markup decription) + [ "$5" != "" ] && markup=',"parse_mode":'"$5" + [ "$6" != "" ] && desc=',"description":"'$6'"' + JSON='{"type":"article","id":"'$ID'","title":"'$3'","message_text":"'$4'"'${markup}${desc}'}' ;; - "photo") - [ "$4" = "" ] && local tumb="$3" - JSON='{"type":"photo","id":"'$ID'","photo_url":"'$3'","thumb_url":"'$4${tumb}'"}' + "photo") # photo ID photoURL (thumbURL title description caption) + [ "$4" = "" ] && tumb="$3" + [ "$5" != "" ] && title=',"title":"'$5'"' + [ "$6" != "" ] && desc=',"description":"'$6'"' + [ "$7" != "" ] && caption=',"caption":"'$7'"' + JSON='{"type":"photo","id":"'$ID'","photo_url":"'$3'","thumb_url":"'$4${tumb}'"'${title}${desc}${caption}'}' ;; - "gif") - [ "$4" = "" ] && local tumb="$3" - JSON='{"type":"gif","id":"'$ID'","gif_url":"'$3'", "thumb_url":"'$4${tumb}'"}' + "gif") # gif ID photoURL (thumbURL title caption) + [ "$4" = "" ] && tumb="$3" + [ "$5" != "" ] && title=',"title":"'$5'"' + [ "$6" != "" ] && caption=',"caption":"'$6'"' + JSON='{"type":"gif","id":"'$ID'","gif_url":"'$3'", "thumb_url":"'$4${tumb}'"'${title}${caption}'}' ;; - "mpeg4_gif") - JSON='{"type":"mpeg4_gif","id":"'$ID'","mpeg4_url":"'$3'"}' + "mpeg4_gif") # mpeg4_gif ID mpegURL (thumbURL title caption) + [ "$4" != "" ] && tumb='","thumb_url":"'$4'"' + [ "$5" != "" ] && title=',"title":"'$5'"' + [ "$6" != "" ] && caption=',"caption":"'$6'"' + JSON='{"type":"mpeg4_gif","id":"'$ID'","mpeg4_url":"'$3'"'${tumb}${title}${caption}'}' ;; - "video") - [ "$5" = "" ] && local tumb="$3" - JSON='{"type":"video","id":"'$ID'","video_url":"'$3'","mime_type":"'$4'","thumb_url":"'$5${tumb}'","title":"'$6'"}' + "video") # video ID videoURL mime thumbURL title (caption) + [ "$7" != "" ] && caption=',"caption":"'$7'"' + JSON='{"type":"video","id":"'$ID'","video_url":"'$3'","mime_type":"'$4'","thumb_url":"'$5'","title":"'$6'"'${caption}'}' ;; - "audio") - JSON='{"type":"audio","id":"'$ID'","audio_url":"'$3'","title":"'$4'"}' + "audio") # audio ID audioURL title (caption) + [ "$5" != "" ] && caption=',"caption":"'$5'"' + JSON='{"type":"audio","id":"'$ID'","audio_url":"'$3'","title":"'$4'"'${caption}'}' ;; - "voice") - JSON='{"type":"voice","id":"'$ID'","voice_url":"'$3'","title":"'$4'"}' + "voice") # voice ID voiceURL title (caption) + [ "$5" != "" ] && caption=',"caption":"'$5'"' + JSON='{"type":"voice","id":"'$ID'","voice_url":"'$3'","title":"'$4'"'${caption}'}' ;; - "document") - JSON='{"type":"document","id":"'$ID'","title":"'$3'","caption":"'$4'","document_url":"'$5'","mime_type":"'$6'"}' + "document") # document ID title documentURL mimetype (caption description) + [ "$6" != "" ] && caption=',"caption":"'$6'"' + [ "$7" != "" ] && desc=',"description":"'$7'"' + JSON='{"type":"document","id":"'$ID'","title":"'$3'","document_url":"'$4'","mime_type":"'$5'"'${caption}${desc}'}' ;; - "location") + "location") # location ID lat long title JSON='{"type":"location","id":"'$ID'","latitude":"'$3'","longitude":"'$4'","title":"'$5'"}' ;; - "venue") - [ "$6" = "" ] && local addr="$5" - JSON='{"type":"venue","id":"'$ID'","latitude":"'$3'","longitude":"'$4'","title":"'$5'","address":"'$6${addr}'"}' + "venue") # venue ID lat long title (adress forsquare) + [ "$6" = "" ] && addr="$5" + [ "$7" != "" ] && fours=',"foursquare_id":"'$7'"' + JSON='{"type":"venue","id":"'$ID'","latitude":"'$3'","longitude":"'$4'","title":"'$5'","address":"'$6${addr}'"'${fours}'}' ;; - "contact") - JSON='{"type":"contact","id":"'$ID'","phone_number":"'$3'","first_name":"'$4'","last_name":"'$5'"}' + "contact") # contact ID phone first (last thumb) + [ "$5" != "" ] && last=',"last_name":"'$5'"' + [ "$6" != "" ] && tumb='","thumb_url":"'$6'"' + JSON='{"type":"contact","id":"'$ID'","phone_number":"'$3'","first_name":"'$4'"'${last}'"}' ;; # Cached media stored in Telegram server - "cached_photo") - JSON='{"type":"photo","id":"'$ID'","photo_file_id":"'$3'"}' + "cached_photo") # photo ID file (title description caption) + [ "$4" != "" ] && title=',"title":"'$4'"' + [ "$5" != "" ] && desc=',"description":"'$5'"' + [ "$6" != "" ] && caption=',"caption":"'$6'"' + JSON='{"type":"photo","id":"'$ID'","photo_file_id":"'$3'"'${title}${desc}${caption}'}' ;; - "cached_gif") - JSON='{"type":"gif","id":"'$ID'","gif_file_id":"'$3'"}' + "cached_gif") # gif ID file (title caption) + [ "$4" != "" ] && title=',"title":"'$4'"' + [ "$5" != "" ] && caption=',"caption":"'$5'"' + JSON='{"type":"gif","id":"'$ID'","gif_file_id":"'$3'"'${title}${caption}'}' ;; - "cached_mpeg4_gif") - JSON='{"type":"mpeg4_gif","id":"'$ID'","mpeg4_file_id":"'$3'"}' + "cached_mpeg4_gif") # mpeg ID file (title caption) + [ "$4" != "" ] && title=',"title":"'$4'"' + [ "$5" != "" ] && caption=',"caption":"'$5'"' + JSON='{"type":"mpeg4_gif","id":"'$ID'","mpeg4_file_id":"'$3'"'${title}${caption}'}' ;; - "cached_sticker") + "cached_sticker") # sticker ID file JSON='{"type":"sticker","id":"'$ID'","sticker_file_id":"'$3'"}' ;; - "cached_document") - JSON='{"type":"document","id":"'$ID'","title":"'$3'","document_file_id":"'$4'"}' + "cached_document") # document ID title file (description caption) + [ "$5" != "" ] && desc=',"description":"'$5'"' + [ "$6" != "" ] && caption=',"caption":"'$6'"' + JSON='{"type":"document","id":"'$ID'","title":"'$3'","document_file_id":"'$4'"'${desc}${caption}'}' ;; - "cached_video") - JSON='{"type":"video","id":"'$ID'","video_file_id":"'$3'","title":"'$4'"}' + "cached_video") # video ID file title (description caption) + [ "$5" != "" ] && desc=',"description":"'$5'"' + [ "$6" != "" ] && caption=',"caption":"'$6'"' + JSON='{"type":"video","id":"'$ID'","video_file_id":"'$3'","title":"'$4'"'${desc}${caption}'}' ;; - "cached_voice") - JSON='{"type":"voice","id":"'$ID'","voice_file_id":"'$3'","title":"'$4'"}' + "cached_voice") # voice ID file title (caption) + [ "$5" != "" ] && caption=',"caption":"'$5'"' + JSON='{"type":"voice","id":"'$ID'","voice_file_id":"'$3'","title":"'$4'"'${caption}'}' ;; - "cached_audio") - JSON='{"type":"audio","id":"'$ID'","audio_file_id":"'$3'"}' + "cached_audio") # audio ID file title (caption) + [ "$5" != "" ] && caption=',"caption":"'$5'"' + JSON='{"type":"audio","id":"'$ID'","audio_file_id":"'$3'"'${caption}'}' ;; esac diff --git a/mycommands.sh b/mycommands.sh index dd9edcc..ddd899b 100644 --- a/mycommands.sh +++ b/mycommands.sh @@ -2,7 +2,7 @@ # files: mycommands.sh.dist # copy to mycommands.sh and add all your commands and functions here ... # -#### $$VERSION$$ v0.80-dev-3-g9bcab66 +#### $$VERSION$$ v0.72-dev-0-g6afa177 # # shellcheck disable=SC2154 # shellcheck disable=SC2034 diff --git a/test/ADD-test-new.sh b/test/ADD-test-new.sh index 883bf0e..771d5dc 100755 --- a/test/ADD-test-new.sh +++ b/test/ADD-test-new.sh @@ -2,7 +2,7 @@ # # ADD a new test skeleton to test dir, but does not activate test # -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script diff --git a/test/ALL-tests.inc.sh b/test/ALL-tests.inc.sh index 1e75d29..c1e025c 100644 --- a/test/ALL-tests.inc.sh +++ b/test/ALL-tests.inc.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # common variables export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME diff --git a/test/a-commit-test.sh b/test/a-commit-test.sh index 3a35f0f..8e9747d 100755 --- a/test/a-commit-test.sh +++ b/test/a-commit-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 ../dev/hooks/pre-commit.sh diff --git a/test/b-example-test.sh b/test/b-example-test.sh index c048870..41a5e1c 100644 --- a/test/b-example-test.sh +++ b/test/b-example-test.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # file: b-example-test.sh -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/c-init-test.sh b/test/c-init-test.sh index a803a40..4ce93c3 100755 --- a/test/c-init-test.sh +++ b/test/c-init-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/d-JSON.sh-test.sh b/test/d-JSON.sh-test.sh index e9ec17e..13c15dc 100755 --- a/test/d-JSON.sh-test.sh +++ b/test/d-JSON.sh-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/d-process_inline-test.sh b/test/d-process_inline-test.sh index 9d3f507..a285b3e 100755 --- a/test/d-process_inline-test.sh +++ b/test/d-process_inline-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.70-6-g5b8f2a2 +#### $$VERSION$$ v0.72-dev-0-g6afa177 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/d-process_message-test.sh b/test/d-process_message-test.sh index 2e708b3..232945a 100755 --- a/test/d-process_message-test.sh +++ b/test/d-process_message-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/d-send_message-test.sh b/test/d-send_message-test.sh index d93a09a..58e1387 100755 --- a/test/d-send_message-test.sh +++ b/test/d-send_message-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/d-user_is-test.sh b/test/d-user_is-test.sh index 2248413..42b30fc 100755 --- a/test/d-user_is-test.sh +++ b/test/d-user_is-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/e-env-test.sh b/test/e-env-test.sh index f591ef5..226a3ed 100755 --- a/test/e-env-test.sh +++ b/test/e-env-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.72-dev-0-g6afa177 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh