mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-06-08 13:20:52 +00:00
inline query loop response
This commit is contained in:
parent
a51f8ca150
commit
a734b5f5ab
|
@ -2,7 +2,7 @@
|
||||||
# files: mycommands.sh.dist
|
# files: mycommands.sh.dist
|
||||||
# copy to mycommands.sh and add all your commands and functions here ...
|
# copy to mycommands.sh and add all your commands and functions here ...
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.72-dev-3-g65b32aa
|
#### $$VERSION$$ v0.72-dev-6-ga51f8ca
|
||||||
#
|
#
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
|
@ -68,14 +68,25 @@ else
|
||||||
"google "*) # search in google images
|
"google "*) # search in google images
|
||||||
local search="${iQUERY#* }"
|
local search="${iQUERY#* }"
|
||||||
answer_inline_multi "${iQUERY[ID]}" "$(my_image_search "${search}")"
|
answer_inline_multi "${iQUERY[ID]}" "$(my_image_search "${search}")"
|
||||||
|
exit
|
||||||
;;
|
;;
|
||||||
"photo")
|
"photo") # manually provide URLs
|
||||||
answer_inline_multi "${iQUERY[ID]}" "
|
answer_inline_multi "${iQUERY[ID]}" "
|
||||||
$(inline_query_compose "$RANDOM" "photo" "https://avatars0.githubusercontent.com/u/13046303"),
|
$(inline_query_compose "$RANDOM" "photo" "https://avatars.githubusercontent.com/u/13046303"),
|
||||||
$(inline_query_compose "$RANDOM" "photo" "https://avatars1.githubusercontent.com/u/4593242")
|
$(inline_query_compose "$RANDOM" "photo" "https://avatars.githubusercontent.com/u/4593242")
|
||||||
"
|
"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
"avatar") # read URLS from array
|
||||||
|
local sep=""
|
||||||
|
local avatar=("https://avatars.githubusercontent.com/u/13046303" "https://avatars.githubusercontent.com/u/4593242" "https://avatars.githubusercontent.com/u/102707" "https://avatars.githubusercontent.com/u/6460407")
|
||||||
|
answer_inline_multi "${iQUERY[ID]}" "
|
||||||
|
$(for photo in ${avatar[*]} ; do
|
||||||
|
echo "${sep}"; inline_query_compose "$RANDOM" "photo" "${photo}" "${photo}"; sep=","
|
||||||
|
done)
|
||||||
|
"
|
||||||
|
;;
|
||||||
|
|
||||||
"sticker")
|
"sticker")
|
||||||
answer_inline_query "${iQUERY[ID]}" "cached_sticker" "BQADBAAD_QEAAiSFLwABWSYyiuj-g4AC"
|
answer_inline_query "${iQUERY[ID]}" "cached_sticker" "BQADBAAD_QEAAiSFLwABWSYyiuj-g4AC"
|
||||||
;;
|
;;
|
||||||
|
@ -90,14 +101,14 @@ else
|
||||||
|
|
||||||
# place your processing functions here
|
# place your processing functions here
|
||||||
|
|
||||||
|
# problem: google returns png :-(
|
||||||
# $1 search parameter
|
# $1 search parameter
|
||||||
my_image_search(){
|
my_image_search(){
|
||||||
local image result
|
local image result sep=""
|
||||||
result="$(wget --user-agent 'Mozilla/5.0' -qO - "https://www.google.com/search?q=$1&tbm=isch" | sed 's/</\n</g' | grep '<img')"
|
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
|
while read -r image; do
|
||||||
image="${image#* src=\"}"; image="${image%%\" width=\"*}"
|
image="${image#* src=\"}"; image="${image%%\" width=\"*}"
|
||||||
echo "$(inline_query_compose "$RANDOM" "photo" "${image}"),"
|
echo "${sep}"; inline_query_compose "$RANDOM" "photo" "${image}"; sep=","
|
||||||
done <<<"${result}"
|
done <<<"${result}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user