diff --git a/commands.sh b/commands.sh index 2c8838d..bc6d76f 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.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 diff --git a/modules/aliases.sh b/modules/aliases.sh index e738984..0c92471 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.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]}" "$@" -} diff --git a/modules/background.sh b/modules/background.sh index 8c4818f..3525a1b 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.72-dev-0-g6afa177 +#### $$VERSION$$ v0.72-dev-3-g65b32aa # source from commands.sh if you want ro use interactive or background jobs diff --git a/modules/inline.sh b/modules/inline.sh index 3ca6b31..7bc10bb 100644 --- a/modules/inline.sh +++ b/modules/inline.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-2-g17d3573 +#### $$VERSION$$ v0.72-dev-3-g65b32aa # source from commands.sh to use the inline functions diff --git a/mycommands.sh b/mycommands.sh index ddd899b..a43eb60 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.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/