mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-22 15:35:09 +00:00
inline query loop response
This commit is contained in:
parent
a51f8ca150
commit
a734b5f5ab
@ -2,7 +2,7 @@
|
||||
# files: mycommands.sh.dist
|
||||
# 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=SC2034
|
||||
@ -68,11 +68,22 @@ else
|
||||
"google "*) # search in google images
|
||||
local search="${iQUERY#* }"
|
||||
answer_inline_multi "${iQUERY[ID]}" "$(my_image_search "${search}")"
|
||||
exit
|
||||
;;
|
||||
"photo")
|
||||
"photo") # manually provide URLs
|
||||
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")
|
||||
$(inline_query_compose "$RANDOM" "photo" "https://avatars.githubusercontent.com/u/13046303"),
|
||||
$(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)
|
||||
"
|
||||
;;
|
||||
|
||||
@ -90,14 +101,14 @@ else
|
||||
|
||||
# place your processing functions here
|
||||
|
||||
# problem: google returns png :-(
|
||||
# $1 search parameter
|
||||
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')"
|
||||
|
||||
while read -r image; do
|
||||
image="${image#* src=\"}"; image="${image%%\" width=\"*}"
|
||||
echo "$(inline_query_compose "$RANDOM" "photo" "${image}"),"
|
||||
echo "${sep}"; inline_query_compose "$RANDOM" "photo" "${image}"; sep=","
|
||||
done <<<"${result}"
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user