From 5cea14003f7d8e248d5e1ea33a3dc78d01373dfa Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Thu, 2 May 2019 15:14:18 +0200 Subject: [PATCH] inline queries working as before --- bashbot.sh | 81 ++------------------------------ commands.sh | 104 ++++++++++++++++++++++-------------------- dev/git-add.sh | 4 +- doc/2_usage.md | 14 +++++- doc/3_advanced.md | 27 +++++------ modules/aliases.sh | 2 +- modules/background.sh | 2 +- modules/inline.sh | 82 ++++++++++++++++++++++++++++++++- mycommands.sh | 4 +- 9 files changed, 173 insertions(+), 147 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index 32427ae..2222a02 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.80-dev-2-g4e4194d +#### $$VERSION$$ v0.80-dev-3-g9bcab66 # # Exit Codes: # - 0 sucess (hopefully) @@ -147,7 +147,6 @@ LOCATION_URL=$URL'/sendLocation' VENUE_URL=$URL'/sendVenue' ACTION_URL=$URL'/sendChatAction' FORWARD_URL=$URL'/forwardMessage' -INLINE_QUERY=$URL'/answerInlineQuery' ME_URL=$URL'/getMe' DELETE_URL=$URL'/deleteMessage' GETMEMBER_URL=$URL'/getChatMember' @@ -156,8 +155,8 @@ UPD_URL=$URL'/getUpdates?offset=' GETFILE_URL=$URL'/getFile' unset USER -declare -A BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE iQUERY -export BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE iQUERY +declare -A BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE +export BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE send_normal_message() { @@ -235,76 +234,6 @@ user_is_allowed() { grep -F -xq "${acl}" <"${BOTACL}" } -answer_inline_query() { - local JSON - case "${2}" in - "article") - JSON='[{"type":"'$2'","id":"'$RANDOM'","title":"'$3'","message_text":"'$4'"}]' - ;; - "photo") - JSON='[{"type":"'$2'","id":"'$RANDOM'","photo_url":"'$3'","thumb_url":"'$4'"}]' - ;; - "gif") - JSON='[{"type":"'$2'","id":"'$RANDOM'","gif_url":"'$3'", "thumb_url":"'$4'"}]' - ;; - "mpeg4_gif") - JSON='[{"type":"'$2'","id":"'$RANDOM'","mpeg4_url":"'$3'"}]' - ;; - "video") - JSON='[{"type":"'$2'","id":"'$RANDOM'","video_url":"'$3'","mime_type":"'$4'","thumb_url":"'$5'","title":"'$6'"}]' - ;; - "audio") - JSON='[{"type":"'$2'","id":"'$RANDOM'","audio_url":"'$3'","title":"'$4'"}]' - ;; - "voice") - JSON='[{"type":"'$2'","id":"'$RANDOM'","voice_url":"'$3'","title":"'$4'"}]' - ;; - "document") - JSON='[{"type":"'$2'","id":"'$RANDOM'","title":"'$3'","caption":"'$4'","document_url":"'$5'","mime_type":"'$6'"}]' - ;; - "location") - JSON='[{"type":"'$2'","id":"'$RANDOM'","latitude":"'$3'","longitude":"'$4'","title":"'$5'"}]' - ;; - "venue") - JSON='[{"type":"'$2'","id":"'$RANDOM'","latitude":"'$3'","longitude":"'$4'","title":"'$5'","address":"'$6'"}]' - ;; - "contact") - JSON='[{"type":"'$2'","id":"'$RANDOM'","phone_number":"'$3'","first_name":"'$4'"}]' - ;; - - # Cached media stored in Telegram server - - "cached_photo") - JSON='[{"type":"photo","id":"'$RANDOM'","photo_file_id":"'$3'"}]' - ;; - "cached_gif") - JSON='[{"type":"gif","id":"'$RANDOM'","gif_file_id":"'$3'"}]' - ;; - "cached_mpeg4_gif") - JSON='[{"type":"mpeg4_gif","id":"'$RANDOM'","mpeg4_file_id":"'$3'"}]' - ;; - "cached_sticker") - JSON='[{"type":"sticker","id":"'$RANDOM'","sticker_file_id":"'$3'"}]' - ;; - "cached_document") - JSON='[{"type":"document","id":"'$RANDOM'","title":"'$3'","document_file_id":"'$4'"}]' - ;; - "cached_video") - JSON='[{"type":"video","id":"'$RANDOM'","video_file_id":"'$3'","title":"'$4'"}]' - ;; - "cached_voice") - JSON='[{"type":"voice","id":"'$RANDOM'","voice_file_id":"'$3'","title":"'$4'"}]' - ;; - "cached_audio") - JSON='[{"type":"audio","id":"'$RANDOM'","audio_file_id":"'$3'"}]' - ;; - - esac - - sendJson "" '"inline_query_id": '"${1}"', "results": '"${JSON}" "${INLINE_QUERY}" -} - - old_send_keyboard() { local text='"text":"'"${2}"'"' shift 2 @@ -454,7 +383,7 @@ process_client() { if [ "${iQUERY[ID]}" = "" ]; then process_message "$PROCESS_NUMBER" else - [ "$INLINE" = 1 ] && _is_function process_inline && process_inline "$PROCESS_NUMBER" + [ "$INLINE" != "0" ] && _is_function process_inline && process_inline "$PROCESS_NUMBER" fi # Tmux copname="$ME"_"${CHAT[ID]}" @@ -560,7 +489,7 @@ start_bot() { local maxsleep="$(( ${BASHBOT_SLEEP:-5000} + 100 ))" while true; do { - UPDATE="$(curl -s "$UPD_URL$OFFSET" | "${JSONSHFILE}")" + UPDATE="$(curl -s "$UPD_URL$OFFSET" | "${JSONSHFILE}" -s -b -n)" # Offset OFFSET="$(echo "$UPDATE" | grep '\["result",[0-9]*,"update_id"\]' | tail -1 | cut -f 2)" diff --git a/commands.sh b/commands.sh index 02810ef..2eab54a 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.80-dev-2-g4e4194d +#### $$VERSION$$ v0.80-dev-3-g9bcab66 # # shellcheck disable=SC2154 # shellcheck disable=SC2034 @@ -19,16 +19,14 @@ export 'LANGUAGE=C.UTF-8' unset IFS # set -f # if you are paranoid use set -f to disable globbing - - - # to change the default info message overwrite bashbot_info in mycommands.sh - bashbot_info='This is bashbot, the Telegram bot written entirely in bash. +# to change the default info message overwrite bashbot_info in mycommands.sh +bashbot_info='This is bashbot, the Telegram bot written entirely in bash. It features background tasks and interactive chats, and can serve as an interface for CLI programs. It currently can send, recieve and forward messages, custom keyboards, photos, audio, voice, documents, locations and video files. ' - # to change the default help messages overwrite in mycommands.sh - bashbot_help='*Available commands*: +# to change the default help messages overwrite in mycommands.sh +bashbot_help='*Available commands*: *• /start*: _Start bot and get this message_. *• /help*: _Get this message_. *• /info*: _Get shorter info message about this bot_. @@ -40,29 +38,29 @@ Written by Drew (@topkecleon), Daniil Gentili (@danogentili) and KayM(@gnadelwar Get the code in my [GitHub](http://github.com/topkecleon/telegram-bot-bash) ' -# load modules -# shellcheck source=./modules/aliases.sh -[ -r "${MODULEDIR:-.}/aliases.sh" ] && source "${MODULEDIR:-.}/aliases.sh" -# shellcheck source=./modules/background.sh -[ -r "${MODULEDIR:-.}/background.sh" ] && source "${MODULEDIR:-.}/background.sh" -# shellcheck source=./modules/background.sh -[ -r "${MODULEDIR:-.}/inline.sh" ] && source "${MODULEDIR:-.}/inline.sh" -# ... more modules here ... - - - -if [ "$1" = "source" ];then +if [ "${1}" != "source" ]; then + # load modules needed for commands.sh only + # shellcheck source=./modules/aliases.sh + [ -r "${MODULEDIR:-.}/aliases.sh" ] && source "${MODULEDIR:-.}/aliases.sh" + # shellcheck source=./modules/background.sh + [ -r "${MODULEDIR:-.}/background.sh" ] && source "${MODULEDIR:-.}/background.sh" +else # defaults to no inline and nonsense home dir INLINE="0" FILE_REGEX='/home/user/allowed/.*' - # shellcheck source=./commands.sh - [ -r "${BASHBOT_ETC:-.}/mycommands.sh" ] && source "${BASHBOT_ETC:-.}/mycommands.sh" "source" -else - # mycommands is the last "module" to source in - # shellcheck source=./commands.sh - [ -r "${BASHBOT_ETC:-.}/mycommands.sh" ] && source "${BASHBOT_ETC:-.}/mycommands.sh" +fi - if ! tmux ls | grep -v send | grep -q "$copname"; then +# load modules needed for bashbot.sh also +# shellcheck source=./modules/background.sh +[ -r "${MODULEDIR:-.}/inline.sh" ] && source "${MODULEDIR:-.}/inline.sh" + +# load mycommands +# shellcheck source=./commands.sh +[ -r "${BASHBOT_ETC:-.}/mycommands.sh" ] && source "${BASHBOT_ETC:-.}/mycommands.sh" "${1}" + + +if [ "${1}" != "source" ];then + if ! tmux ls | grep -v send | grep -q "$copname"; then # interactive running? [ ! -z "${URLS[*]}" ] && { curl -s "${URLS[*]}" -o "$NAME" @@ -71,32 +69,37 @@ else } [ ! -z "${LOCATION[*]}" ] && send_location "${CHAT[ID]}" "${LOCATION[LATITUDE]}" "${LOCATION[LONGITUDE]}" - # Inline - if [ "$INLINE" = 1 ]; then - # inline query data - iUSER[FIRST_NAME]="$(echo "$res" | sed 's/^.*\(first_name.*\)/\1/g' | cut -d '"' -f3 | tail -1)" - iUSER[LAST_NAME]="$(echo "$res" | sed 's/^.*\(last_name.*\)/\1/g' | cut -d '"' -f3)" - iUSER[USERNAME]="$(echo "$res" | sed 's/^.*\(username.*\)/\1/g' | cut -d '"' -f3 | tail -1)" - iQUERY_ID="$(echo "$res" | sed 's/^.*\(inline_query.*\)/\1/g' | cut -d '"' -f5 | tail -1)" - iQUERY_MSG="$(echo "$res" | sed 's/^.*\(inline_query.*\)/\1/g' | cut -d '"' -f5 | tail -6 | head -1)" + fi - # Inline examples - if [[ "$iQUERY_MSG" = "photo" ]]; then - answer_inline_query "$iQUERY_ID" "photo" "http://blog.techhysahil.com/wp-content/uploads/2016/01/Bash_Scripting.jpeg" "http://blog.techhysahil.com/wp-content/uploads/2016/01/Bash_Scripting.jpeg" - fi + if [ "$INLINE" != "0" ] && [ "${iQUERY[ID]}" != "" ]; then + if _is_function process_inline; then + ####################### + # Inline query examples + case "$iQUERY" in + "photo") + answer_inline_query "${iQUERY[ID]}" "photo" "http://blog.techhysahil.com/wp-content/uploads/2016/01/Bash_Scripting.jpeg" "http://blog.techhysahil.com/wp-content/uploads/2016/01/Bash_Scripting.jpeg" + ;; - if [[ "$iQUERY_MSG" = "sticker" ]]; then - answer_inline_query "$iQUERY_ID" "cached_sticker" "BQADBAAD_QEAAiSFLwABWSYyiuj-g4AC" - fi - - if [[ "$iQUERY_MSG" = "gif" ]]; then - answer_inline_query "$iQUERY_ID" "cached_gif" "BQADBAADIwYAAmwsDAABlIia56QGP0YC" - fi - if [[ "$iQUERY_MSG" = "web" ]]; then - answer_inline_query "$iQUERY_ID" "article" "GitHub" "http://github.com/topkecleon/telegram-bot-bash" - fi - fi & # note the & ! + "sticker") + answer_inline_query "${iQUERY[ID]}" "cached_sticker" "BQADBAAD_QEAAiSFLwABWSYyiuj-g4AC" + ;; + "gif") + answer_inline_query "${iQUERY[ID]}" "cached_gif" "BQADBAADIwYAAmwsDAABlIia56QGP0YC" + ;; + "web") + answer_inline_query "${iQUERY[ID]}" "article" "GitHub" "http://github.com/topkecleon/telegram-bot-bash" + ;; + ################################################ + # GLOBAL commands start here, edit messages only + '/info'*) + answer_inline_query "${iQUERY[ID]}" "article" "${bashbot_info}" + ;; + *) # forward iinline query to optional dispatcher + _is_function myinlines && myinlines + esac fi + else + case "$MESSAGE" in ################################################ # GLOBAL commands start here, edit messages only @@ -132,9 +135,10 @@ else checkproc if [ "$res" -eq 0 ] ; then killproc && _message "Command canceled.";else _message "No command is currently running.";fi ;; - *) # forward other messages to optional dispatcher + *) # forward messages to optional dispatcher _is_function startproc && if tmux ls | grep -v send | grep -q "$copname"; then inproc; fi # interactive running _is_function mycommands && mycommands ;; esac + fi fi diff --git a/dev/git-add.sh b/dev/git-add.sh index 1ebc829..b4d1b9c 100755 --- a/dev/git-add.sh +++ b/dev/git-add.sh @@ -3,14 +3,14 @@ # # works together with git pre-push.sh and ADD all changed files since last push -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.80-dev-3-g9bcab66 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script GIT_DIR=$(git rev-parse --git-dir) cd "$GIT_DIR/.." || exit 1 -[ -f .git/.lastpush ] || echo "No push or hooks not installed, use \"git add\" instead ... Abort" && exit +[ ! -f .git/.lastpush ] && echo "No push or hooks not installed, use \"git add\" instead ... Abort" && exit FILES="$(find ./* -newer .git/.lastpush)" [ "${FILES}" = "" ] && echo "Noting changed since last push ... Abort" && exit diff --git a/doc/2_usage.md b/doc/2_usage.md index a75610b..cd04160 100644 --- a/doc/2_usage.md +++ b/doc/2_usage.md @@ -37,6 +37,8 @@ To send a broadcast to all of users that ever used the bot run the following com ## Recieve data Evertime a Message is recieved, you can read incoming data using the following variables: +### Regular Messages + * ```${MESSAGE}```: Current message * ```${MESSAGE[ID]}```: ID of current message * ```$CAPTION```: Captions @@ -89,6 +91,16 @@ Evertime a Message is recieved, you can read incoming data using the following v * ```${VENUE[LATITUDE]}```: Latitude * ```${VENUE[FOURSQUARE]}```: Fouresquare ID +### Inline queries +Evertime a Message is recieved, you can read incoming data using the following variables: + +* ```${iQUERY}```: Current inline query +* ```$iQUERY```: This array contains the ID, First name, last name, username and user id of the sender of the current inline query. + * ```${iQUERY[ID]}```: Inline query ID + * ```${iQUERY[USER_ID]}```: User's id + * ```${iQUERY[FIRST_NAME]}```: User's first name + * ```${iQUERY[LAST_NAME]}```: User's last name + ## Usage of bashbot functions #### sending messages @@ -167,5 +179,5 @@ send_action "${CHAT[ID]}" "action" #### [Prev Create Bot](1_firstbot.md) #### [Next Advanced Usage](3_advanced.md) -#### $$VERSION$$ v0.80-dev-2-g4e4194d +#### $$VERSION$$ v0.80-dev-3-g9bcab66 diff --git a/doc/3_advanced.md b/doc/3_advanced.md index 630115e..11c6620 100644 --- a/doc/3_advanced.md +++ b/doc/3_advanced.md @@ -133,49 +133,50 @@ If you want to kill all background jobs permantly run: Note: Background Jobs run independent from main bot and continue running until your script exits or you stop if from your Bot. Backgound Jobs will continue running if your Bot is stopeda and must be terminated, e.g. by ```bashbot.sh killback``` ### Inline queries -The following commands allows users to interact with your bot via *inline queries*. +**Inline queries** allow users to send commands to your bot from every chat without going to a private chat. An inline query is started if the user type the bots name, e.g. @myBot. Everything after @myBot is immediatly send to the bot. + In order to enable **inline mode**, send `/setinline` command to [@BotFather](https://telegram.me/botfather) and provide the placeholder text that the user will see in the input field after typing your bot’s name. -Also, edit line 12 from `commands.sh` putting a "1". -Note that you can't modify the first two parameters of the function `answer_inline_query`, only the ones after them. + +The following commands allows you to send ansers to *inline queries*. To enable bashbot to process inline queries set ```INLINE="1"``` in 'mycommands.sh'. To send messsages or links through an *inline query*: ```bash -answer_inline_query "$iQUERY_ID" "article" "Title of the result" "Content of the message to be sent" +answer_inline_query "${iQUERY[ID]}" "article" "Title of the result" "Content of the message to be sent" ``` To send photos in jpeg format and less than 5MB, from a website through an *inline query*: ```bash -answer_inline_query "$iQUERY_ID" "photo" "A valid URL of the photo" "URL of the thumbnail" +answer_inline_query "${iQUERY[ID]}" "photo" "A valid URL of the photo" "URL of the thumbnail" ``` To send standard gifs from a website (less than 1MB) through an *inline query*: ```bash -answer_inline_query "$iQUERY_ID" "gif" "gif url" +answer_inline_query "${iQUERY[ID]}" "gif" "gif url" ``` To send mpeg4 gifs from a website (less than 1MB) through an *inline query*: ```bash -answer_inline_query "$iQUERY_ID" "mpeg4_gif" "mpeg4 gif url" +answer_inline_query "${iQUERY[ID]}" "mpeg4_gif" "mpeg4 gif url" ``` To send videos from a website through an *inline query*: ```bash -answer_inline_query "$iQUERY_ID" "video" "valid video url" "Select one mime type: text/html or video/mp4" "URL of the thumbnail" "Title for the result" +answer_inline_query "${iQUERY[ID]}" "video" "valid video url" "Select one mime type: text/html or video/mp4" "URL of the thumbnail" "Title for the result" ``` To send photos stored in Telegram servers through an *inline query*: ```bash -answer_inline_query "$iQUERY_ID" "cached_photo" "identifier for the photo" +answer_inline_query "${iQUERY[ID]}" "cached_photo" "identifier for the photo" ``` To send gifs stored in Telegram servers through an *inline query*: ```bash -answer_inline_query "$iQUERY_ID" "cached_gif" "identifier for the gif" +answer_inline_query "${iQUERY[ID]}" "cached_gif" "identifier for the gif" ``` To send mpeg4 gifs stored in Telegram servers through an *inline query*: ```bash -answer_inline_query "$iQUERY_ID" "cached_mpeg4_gif" "identifier for the gif" +answer_inline_query "${iQUERY[ID]}" "cached_mpeg4_gif" "identifier for the gif" ``` To send stickers through an *inline query*: ```bash -answer_inline_query "$iQUERY_ID" "cached_sticker" "identifier for the sticker" +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-2-g4e4194d +#### $$VERSION$$ v0.80-dev-3-g9bcab66 diff --git a/modules/aliases.sh b/modules/aliases.sh index f8091e7..33ba090 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.80-dev-2-g4e4194d +#### $$VERSION$$ v0.80-dev-3-g9bcab66 # # source from commands.sh to use the aliases diff --git a/modules/background.sh b/modules/background.sh index 6a32e9c..73622c4 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-2-g4e4194d +#### $$VERSION$$ v0.80-dev-3-g9bcab66 # source from commands.sh if you want ro use interactive or background jobs diff --git a/modules/inline.sh b/modules/inline.sh index be657dc..2d8cc82 100644 --- a/modules/inline.sh +++ b/modules/inline.sh @@ -5,10 +5,90 @@ # 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.80-dev-3-g9bcab66 # source from commands.sh to use the inline functions +INLINE_QUERY=$URL'/answerInlineQuery' +declare -A iQUERY +export iQUERY + process_inline() { echo "$UPDATE" >>INLINE.log + iQUERY[0]="$(JsonDecode "$(JsonGetString <<<"${UPDATE}" '"result",'"$PROCESS_NUMBER"',"inline_query","query"')")" + iQUERY[USER_ID]="$(JsonGetString <<<"${UPDATE}" '"result",'"$PROCESS_NUMBER"',"inline_query","from","id"')" + iQUERY[FIRST_NAME]="$(JsonDecode "$(JsonGetString <<<"${UPDATE}" '"result",'"$PROCESS_NUMBER"',"inline_query","from","first_name"')")" + iQUERY[LAST_NAME]="$(JsonDecode "$(JsonGetString <<<"${UPDATE}" '"result",'"$PROCESS_NUMBER"',"inline_query","from","last_name"')")" + iQUERY[USERNAME]="$(JsonDecode "$(JsonGetString <<<"${UPDATE}" '"result",'"$PROCESS_NUMBER"',"inline_query","from","username"')")" } + + +answer_inline_query() { + local JSON + case "${2}" in + "article") + JSON='[{"type":"'$2'","id":"'$RANDOM'","title":"'$3'","message_text":"'$4'"}]' + ;; + "photo") + JSON='[{"type":"'$2'","id":"'$RANDOM'","photo_url":"'$3'","thumb_url":"'$4'"}]' + ;; + "gif") + JSON='[{"type":"'$2'","id":"'$RANDOM'","gif_url":"'$3'", "thumb_url":"'$4'"}]' + ;; + "mpeg4_gif") + JSON='[{"type":"'$2'","id":"'$RANDOM'","mpeg4_url":"'$3'"}]' + ;; + "video") + JSON='[{"type":"'$2'","id":"'$RANDOM'","video_url":"'$3'","mime_type":"'$4'","thumb_url":"'$5'","title":"'$6'"}]' + ;; + "audio") + JSON='[{"type":"'$2'","id":"'$RANDOM'","audio_url":"'$3'","title":"'$4'"}]' + ;; + "voice") + JSON='[{"type":"'$2'","id":"'$RANDOM'","voice_url":"'$3'","title":"'$4'"}]' + ;; + "document") + JSON='[{"type":"'$2'","id":"'$RANDOM'","title":"'$3'","caption":"'$4'","document_url":"'$5'","mime_type":"'$6'"}]' + ;; + "location") + JSON='[{"type":"'$2'","id":"'$RANDOM'","latitude":"'$3'","longitude":"'$4'","title":"'$5'"}]' + ;; + "venue") + JSON='[{"type":"'$2'","id":"'$RANDOM'","latitude":"'$3'","longitude":"'$4'","title":"'$5'","address":"'$6'"}]' + ;; + "contact") + JSON='[{"type":"'$2'","id":"'$RANDOM'","phone_number":"'$3'","first_name":"'$4'"}]' + ;; + + # Cached media stored in Telegram server + + "cached_photo") + JSON='[{"type":"photo","id":"'$RANDOM'","photo_file_id":"'$3'"}]' + ;; + "cached_gif") + JSON='[{"type":"gif","id":"'$RANDOM'","gif_file_id":"'$3'"}]' + ;; + "cached_mpeg4_gif") + JSON='[{"type":"mpeg4_gif","id":"'$RANDOM'","mpeg4_file_id":"'$3'"}]' + ;; + "cached_sticker") + JSON='[{"type":"sticker","id":"'$RANDOM'","sticker_file_id":"'$3'"}]' + ;; + "cached_document") + JSON='[{"type":"document","id":"'$RANDOM'","title":"'$3'","document_file_id":"'$4'"}]' + ;; + "cached_video") + JSON='[{"type":"video","id":"'$RANDOM'","video_file_id":"'$3'","title":"'$4'"}]' + ;; + "cached_voice") + JSON='[{"type":"voice","id":"'$RANDOM'","voice_file_id":"'$3'","title":"'$4'"}]' + ;; + "cached_audio") + JSON='[{"type":"audio","id":"'$RANDOM'","audio_file_id":"'$3'"}]' + ;; + + esac + + sendJson "" '"inline_query_id": '"${1}"', "results": '"${JSON}" "${INLINE_QUERY}" +} + diff --git a/mycommands.sh b/mycommands.sh index 3480e0a..dd9edcc 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-2-g4e4194d +#### $$VERSION$$ v0.80-dev-3-g9bcab66 # # shellcheck disable=SC2154 # shellcheck disable=SC2034 @@ -17,7 +17,7 @@ if [ "$1" = "source" ];then # Set INLINE to 1 in order to receive inline queries. # To enable this option in your bot, send the /setinline command to @BotFather. - INLINE="0" + INLINE="1" # Set to .* to allow sending files from all locations FILE_REGEX='/home/user/allowed/.*'