mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-12-27 20:44:53 +00:00
make iQUERY[ID] work again
This commit is contained in:
parent
65b32aa2bd
commit
bf00d33122
34
commands.sh
34
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.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
|
||||
|
||||
|
@ -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]}" "$@"
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user