make iQUERY[ID] work again

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2019-05-09 23:34:45 +02:00
parent 65b32aa2bd
commit bf00d33122
5 changed files with 47 additions and 40 deletions

View File

@ -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.72-dev-0-g6afa177
#### $$VERSION$$ v0.72-dev-3-g65b32aa
#
# shellcheck disable=SC2154
# shellcheck disable=SC2034
@ -52,7 +52,6 @@ else
# load modules needed for bashbot.sh also
# shellcheck source=./modules/background.sh
[ -r "${MODULEDIR:-.}/inline.sh" ] && source "${MODULEDIR:-.}/inline.sh"
fi
# load mycommands
@ -72,37 +71,10 @@ if [ "${1}" != "source" ];then
fi
if [ "$INLINE" != "0" ] && [ "${iQUERY[ID]}" != "" ]; then
if _is_function process_inline; then
#######################
# Inline query examples
# shellcheck disable=SC2128
case "${iQUERY}" in
"photo")
answer_inline_multi "${iQUERY[ID]}" "
$(inline_query_compose "$RANDOM" "photo" "https://avatars0.githubusercontent.com/u/13046303"),
$(inline_query_compose "$RANDOM" "photo" "https://avatars1.githubusercontent.com/u/4593242")
"
;;
"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
# forward iinline query to optional dispatcher
_is_function myinlines && myinlines
fi
else

View File

@ -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.72-dev-0-g6afa177
#### $$VERSION$$ v0.72-dev-3-g65b32aa
#
# source from commands.sh to use the aliases
@ -60,8 +60,3 @@ _keyboard_yesno() {
_del_keyboard() {
remove_keyboard "${CHAT[ID]}" ""
}
# inline query
iQUERY[ID]=""
_answer_inline() {
_is_function answer_inline_query && answer_inline_query "${iQUERY[ID]}" "$@"
}

View File

@ -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.72-dev-0-g6afa177
#### $$VERSION$$ v0.72-dev-3-g65b32aa
# source from commands.sh if you want ro use interactive or background jobs

View File

@ -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.72-dev-2-g17d3573
#### $$VERSION$$ v0.72-dev-3-g65b32aa
# source from commands.sh to use the inline functions

View File

@ -2,7 +2,7 @@
# files: mycommands.sh.dist
# copy to mycommands.sh and add all your commands and functions here ...
#
#### $$VERSION$$ v0.72-dev-0-g6afa177
#### $$VERSION$$ v0.72-dev-3-g65b32aa
#
# shellcheck disable=SC2154
# shellcheck disable=SC2034
@ -60,5 +60,45 @@ else
esac
}
myinlines() {
#######################
# Inline query examples
# shellcheck disable=SC2128
case "${iQUERY}" in
"google "*) # search in google images
local search="${iQUERY#* }"
answer_inline_multi "${iQUERY[ID]}" "$(my_image_search "${search}")"
;;
"photo")
answer_inline_multi "${iQUERY[ID]}" "
$(inline_query_compose "$RANDOM" "photo" "https://avatars0.githubusercontent.com/u/13046303"),
$(inline_query_compose "$RANDOM" "photo" "https://avatars1.githubusercontent.com/u/4593242")
"
;;
"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"
;;
esac
}
# place your processing functions here
# $1 search parameter
my_image_search(){
local image result
result="$(wget --user-agent 'Mozilla/5.0' -qO - "https://www.google.com/search?q=$1&tbm=isch" | sed 's/</\n</g' | grep '<img')"
while read -r image; do
image="${image#* src=\"}"; image="${image%%\" width=\"*}"
echo "$(inline_query_compose "$RANDOM" "photo" "${image}"),"
done <<<"${result}"
}
fi