start 0.90-dev - convert to array

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2019-05-22 18:43:20 +02:00
parent 75691dc685
commit 5e6d62f19f
56 changed files with 117 additions and 113 deletions

View File

@ -108,6 +108,6 @@
<p><span class="citation">@Gnadelwartz</span></p> <p><span class="citation">@Gnadelwartz</span></p>
<h2 id="thats-it">Thats it!</h2> <h2 id="thats-it">Thats it!</h2>
<p>If you feel that theres something missing or if you found a bug, feel free to submit a pull request!</p> <p>If you feel that theres something missing or if you found a bug, feel free to submit a pull request!</p>
<h4 id="version-v0.80-0-g5bce3f7"><br /><span class="math display"><em>V</em><em>E</em><em>R</em><em>S</em><em>I</em><em>O</em><em>N</em></span><br /> v0.80-0-g5bce3f7</h4> <h4 id="version-v0.90-dev-0-g75691dc"><br /><span class="math display"><em>V</em><em>E</em><em>R</em><em>S</em><em>I</em><em>O</em><em>N</em></span><br /> v0.90-dev-0-g75691dc</h4>
</body> </body>
</html> </html>

View File

@ -109,4 +109,4 @@ Hey no Problem, if you are finished with your cool bot run ```dev/make-standalon
If you feel that there's something missing or if you found a bug, feel free to submit a pull request! If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc

View File

@ -158,4 +158,4 @@ down Version of your Bot](doc/7_develop.md)
If you feel that there's something missing or if you found a bug, feel free to If you feel that there's something missing or if you found a bug, feel free to
submit a pull request! submit a pull request!
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# description: Start or stop telegram-bash-bot # description: Start or stop telegram-bash-bot
# #
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# shellcheck disable=SC2009 # shellcheck disable=SC2009
# shellcheck disable=SC2181 # shellcheck disable=SC2181

View File

@ -11,7 +11,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# #
# Exit Codes: # Exit Codes:
# - 0 sucess (hopefully) # - 0 sucess (hopefully)
@ -20,6 +20,7 @@
# - 3 user / command / file not found # - 3 user / command / file not found
# - 4 unkown command # - 4 unkown command
# - 5 cannot connect to telegram bot # - 5 cannot connect to telegram bot
# shellcheck disable=SC2140
# are we runnig in a terminal? # are we runnig in a terminal?
if [ -t 1 ] && [ "$TERM" != "" ]; then if [ -t 1 ] && [ "$TERM" != "" ]; then
@ -115,8 +116,8 @@ UPD_URL=$URL'/getUpdates?offset='
GETFILE_URL=$URL'/getFile' GETFILE_URL=$URL'/getFile'
unset USER unset USER
declare -A BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE iQUERY declare -A UPD BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE iQUERY
export res BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE iQUERY CAPTION export res UPD BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE iQUERY CAPTION
COMMANDS="${BASHBOT_ETC:-.}/commands.sh" COMMANDS="${BASHBOT_ETC:-.}/commands.sh"
if [ "$1" != "source" ]; then if [ "$1" != "source" ]; then
@ -282,13 +283,15 @@ JsonGetValue() {
process_updates() { process_updates() {
local max num debug="$1" local max num debug="$1"
max="$(sed <<< "${UPDATE}" '/\["result",[0-9]*\]/!d' | tail -1 | sed 's/\["result",//g;s/\].*//g')" max="$(sed <<< "${UPDATE}" '/\["result",[0-9]*\]/!d' | tail -1 | sed 's/\["result",//g;s/\].*//g')"
# shellcheck source=./commands.sh
source <( printf 'UPD=( %s )' "$(sed <<<"${UPDATE}" -E -e 's/\t/=/g' -e 's/=(true|false)/="\1"/')" )
for ((num=0; num<=max; num++)); do for ((num=0; num<=max; num++)); do
process_client "$num" "${debug}" process_client "$num" "${debug}"
done done
} }
process_client() { process_client() {
local num="$1" debug="$2" local num="$1" debug="$2"
iQUERY[ID]="$(JsonGetString <<<"${UPDATE}" '"result",'"${num}"',"inline_query","id"')" iQUERY[ID]="${UPD["result",${num},"inline_query","id"]}"
if [ "${iQUERY[ID]}" = "" ]; then if [ "${iQUERY[ID]}" = "" ]; then
[[ "${debug}" = *"debug"* ]] && cat <<< "$UPDATE" >>"MESSAGE.log" [[ "${debug}" = *"debug"* ]] && cat <<< "$UPDATE" >>"MESSAGE.log"
process_message "${num}" "${debug}" process_message "${num}" "${debug}"
@ -304,92 +307,90 @@ process_client() {
} }
process_inline() { process_inline() {
local num="${1}" local num="${1}"
iQUERY[0]="$(JsonDecode "$(JsonGetString <<<"${UPDATE}" '"result",0,"inline_query","query"')")" iQUERY[0]="$(JsonDecode "${UPD["result",${num},"inline_query","query"]}")"
iQUERY[USER_ID]="$(JsonGetValue <<<"${UPDATE}" '"result",'"${num}"',"inline_query","from","id"')" iQUERY[USER_ID]="${UPD["result",${num},"inline_query","from","id"]}"
iQUERY[FIRST_NAME]="$(JsonDecode "$(JsonGetString <<<"${UPDATE}" '"result",'"${num}"',"inline_query","from","first_name"')")" iQUERY[FIRST_NAME]="$(JsonDecode "${UPD["result",${num},"inline_query","from","first_name"]}")"
iQUERY[LAST_NAME]="$(JsonDecode "$(JsonGetString <<<"${UPDATE}" '"result",'"${num}"',"inline_query","from","last_name"')")" iQUERY[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"inline_query","from","last_name"]}")"
iQUERY[USERNAME]="$(JsonDecode "$(JsonGetString <<<"${UPDATE}" '"result",'"${num}"',"inline_query","from","username"')")" iQUERY[USERNAME]="$(JsonDecode "${UPD["result",${num},"inline_query","from","username"]}")"
} }
process_message() { process_message() {
local num="$1" local num="$1"
local TMP="${TMPDIR:-.}/$RANDOM$RANDOM-MESSAGE"
cat <<< "$UPDATE" >"$TMP"
# Message # Message
MESSAGE[0]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","text"' <"$TMP")" | sed 's#\\/#/#g')" MESSAGE[0]="$(JsonDecode "${UPD["result",${num},"message","text"]}" | sed 's#\\/#/#g')"
MESSAGE[ID]="$(JsonGetValue '"result",'"${num}"',"message","message_id"' <"$TMP" )" MESSAGE[ID]="${UPD["result",${num},"message","message_id"]}"
# Chat # Chat
CHAT[ID]="$(JsonGetValue '"result",'"${num}"',"message","chat","id"' <"$TMP" )" CHAT[ID]="${UPD["result",${num},"message","chat","id"]}"
CHAT[FIRST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","chat","first_name"' <"$TMP")")" CHAT[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"message","chat","last_name"]}")"
CHAT[LAST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","chat","last_name"' <"$TMP")")" CHAT[FIRST_NAME]="$(JsonDecode "${UPD["result",${num},"message","chat","first_name"]}")"
CHAT[USERNAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","chat","username"' <"$TMP")")" CHAT[USERNAME]="$(JsonDecode "${UPD["result",${num},"message","chat","username"]}")"
CHAT[TITLE]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","chat","title"' <"$TMP")")" CHAT[TITLE]="$(JsonDecode "${UPD["result",${num},"message","chat","title"]}")"
CHAT[TYPE]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","chat","type"' <"$TMP")")" CHAT[TYPE]="$(JsonDecode "${UPD["result",${num},"message","chat","type"]}")"
CHAT[ALL_MEMBERS_ARE_ADMINISTRATORS]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","chat","all_members_are_administrators"' <"$TMP")")" CHAT[ALL_ADMIN]="${UPD["result",${num},"message","chat","all_members_are_administrators"]}"
CHAT[ALL_MEMBERS_ARE_ADMINISTRATORS]="${CHAT[ALL_ADMIN]}" # backward compatibility
# User # User
USER[ID]="$(JsonGetValue '"result",'"${num}"',"message","from","id"' <"$TMP" )" USER[ID]="${UPD["result",${num},"message","from","id"]}"
USER[FIRST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","from","first_name"' <"$TMP")")" USER[FIRST_NAME]="$(JsonDecode "${UPD["result",${num},"message","from","first_name"]}")"
USER[LAST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","from","last_name"' <"$TMP")")" USER[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"message","from","last_name"]}")"
USER[USERNAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","from","username"' <"$TMP")")" USER[USERNAME]="$(JsonDecode "${UPD["result",${num},"message","from","username"]}")"
# in reply to message from # in reply to message from
REPLYTO[UID]="$(JsonGetValue '"result",'"${num}"',"message","reply_to_message","from","id"' <"$TMP" )" REPLYTO[UID]="${UPD["result",${num},"message","reply_to_message","from","id"]}"
if [ "${REPLYTO[UID]}" != "" ]; then if [ "${REPLYTO[UID]}" != "" ]; then
REPLYTO[0]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","reply_to_message","text"' <"$TMP")")" REPLYTO[0]="$(JsonDecode "${UPD["result",${num},"message","reply_to_message","text"]}")"
REPLYTO[ID]="$(JsonGetValue '"result",'"${num}"',"message","reply_to_message","message_id"' <"$TMP")" REPLYTO[ID]="${UPD["result",${num},"message","reply_to_message","message_id"]}"
REPLYTO[FIRST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","reply_to_message","from","first_name"' <"$TMP")")" REPLYTO[FIRST_NAME]="$(JsonDecode "${UPD["result",${num},"message","reply_to_message","from","first_name"]}")"
REPLYTO[LAST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","reply_to_message","from","last_name"' <"$TMP")")" REPLYTO[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"message","reply_to_message","from","last_name"]}")"
REPLYTO[USERNAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","reply_to_message","from","username"' <"$TMP")")" REPLYTO[USERNAME]="$(JsonDecode "${UPD["result",${num},"message","reply_to_message","from","username"]}")"
fi fi
# forwarded message from # forwarded message from
FORWARD[UID]="$(JsonGetValue '"result",'"${num}"',"message","forward_from","id"' <"$TMP" )" FORWARD[UID]="${UPD["result",${num},"message","forward_from","id"]}"
if [ "${FORWARD[UID]}" != "" ]; then if [ "${FORWARD[UID]}" != "" ]; then
FORWARD[ID]="${MESSAGE[ID]}" # same as message ID FORWARD[ID]="${MESSAGE[ID]}" # same as message ID
FORWARD[FIRST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","forward_from","first_name"' <"$TMP")")" FORWARD[FIRST_NAME]="$(JsonDecode "${UPD["result",${num},"message","forward_from","first_name"]}")"
FORWARD[LAST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","forward_from","last_name"' <"$TMP")")" FORWARD[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"message","forward_from","last_name"]}")"
FORWARD[USERNAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","forward_from","username"' <"$TMP")")" FORWARD[USERNAME]="$(JsonDecode "${UPD["result",${num},"message","forward_from","username"]}")"
fi fi
# Audio # Audio
URLS[AUDIO]="$(get_file "$(JsonGetString '"result",'"${num}"',"message","audio","file_id"' <"$TMP")")" URLS[AUDIO]="$(get_file "${UPD["result",${num},"message","audio","file_id"]}")"
# Document # Document
URLS[DOCUMENT]="$(get_file "$(JsonGetString '"result",'"${num}"',"message","document","file_id"' <"$TMP")")" URLS[DOCUMENT]="$(get_file "${UPD["result",${num},"message","document","file_id"]}")"
# Photo # Photo
URLS[PHOTO]="$(get_file "$(JsonGetString '"result",'"${num}"',"message","photo",0,"file_id"' <"$TMP")")" URLS[PHOTO]="$(get_file "${UPD["result",${num},"message","photo",0,"file_id"]}")"
# Sticker # Sticker
URLS[STICKER]="$(get_file "$(JsonGetString '"result",'"${num}"',"message","sticker","file_id"' <"$TMP")")" URLS[STICKER]="$(get_file "${UPD["result",${num},"message","sticker","file_id"]}")"
# Video # Video
URLS[VIDEO]="$(get_file "$(JsonGetString '"result",'"${num}"',"message","video","file_id"' <"$TMP")")" URLS[VIDEO]="$(get_file "${UPD["result",${num},"message","video","file_id"]}")"
# Voice # Voice
URLS[VOICE]="$(get_file "$(JsonGetString '"result",'"${num}"',"message","voice","file_id"' <"$TMP")")" URLS[VOICE]="$(get_file "${UPD["result",${num},"message","voice","file_id"]}")"
# Contact # Contact
CONTACT[FIRST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","contact","first_name"' <"$TMP")")" CONTACT[FIRST_NAME]="$(JsonDecode "${UPD["result",${num},"message","contact","first_name"]}")"
if [ "${CONTACT[FIRST_NAME]}" != "" ]; then if [ "${CONTACT[FIRST_NAME]}" != "" ]; then
CONTACT[USER_ID]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","contact","user_id"' <"$TMP")")" CONTACT[USER_ID]="$(JsonDecode "${UPD["result",${num},"message","contact","user_id"]}")"
CONTACT[LAST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","contact","last_name"' <"$TMP")")" CONTACT[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"message","contact","last_name"]}")"
CONTACT[NUMBER]="$(JsonGetString '"result",'"${num}"',"message","contact","phone_number"' <"$TMP")" CONTACT[NUMBER]="${UPD["result",${num},"message","contact","phone_number"]}"
CONTACT[VCARD]="$(JsonGetString '"result",'"${num}"',"message","contact","vcard"' <"$TMP")" CONTACT[VCARD]="$(JsonGetString '"result",'"${num}"',"message","contact","vcard"' <<<"${UPDATE}")"
fi fi
# vunue # vunue
VENUE[TITLE]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","venue","title"' <"$TMP")")" VENUE[TITLE]="$(JsonDecode "${UPD["result",${num},"message","venue","title"]}")"
if [ "${VENUE[TITLE]}" != "" ]; then if [ "${VENUE[TITLE]}" != "" ]; then
VENUE[ADDRESS]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","venue","address"' <"$TMP")")" VENUE[ADDRESS]="$(JsonDecode "${UPD["result",${num},"message","venue","address"]}")"
VENUE[LONGITUDE]="$(JsonGetValue '"result",'"${num}"',"message","venue","location","longitude"' <"$TMP")" VENUE[LONGITUDE]="${UPD["result",${num},"message","venue","location","longitude"]}"
VENUE[LATITUDE]="$(JsonGetValue '"result",'"${num}"',"message","venue","location","latitude"' <"$TMP")" VENUE[LATITUDE]="${UPD["result",${num},"message","venue","location","latitude"]}"
VENUE[FOURSQUARE]="$(JsonGetString '"result",'"${num}"',"message","venue","foursquare_id"' <"$TMP")" VENUE[FOURSQUARE]="${UPD["result",${num},"message","venue","foursquare_id"]}"
fi fi
# Caption # Caption
CAPTION="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","caption"' <"$TMP")")" CAPTION="$(JsonDecode "${UPD["result",${num},"message","caption"]}")"
# Location # Location
LOCATION[LONGITUDE]="$(JsonGetValue '"result",'"${num}"',"message","location","longitude"' <"$TMP")" LOCATION[LONGITUDE]="${UPD["result",${num},"message","location","longitude"]}"
LOCATION[LATITUDE]="$(JsonGetValue '"result",'"${num}"',"message","location","latitude"' <"$TMP")" LOCATION[LATITUDE]="${UPD["result",${num},"message","location","latitude"]}"
rm "$TMP"
} }

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# #
# adjust your language setting here, e.g.when run from other user or cron. # adjust your language setting here, e.g.when run from other user or cron.

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# this has to run once atfer git clone # this has to run once atfer git clone
# and every time we create new hooks # and every time we create new hooks
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# magic to ensure that we're always inside the root of our application, # magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script # no matter from which directory we'll run script

View File

@ -3,7 +3,7 @@
# #
# works together with git pre-push.sh and ADD all changed files since last push # works together with git pre-push.sh and ADD all changed files since last push
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# magic to ensure that we're always inside the root of our application, # magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script # no matter from which directory we'll run script

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
############ ############
# NOTE: you MUST run install-hooks.sh again when updating this file! # NOTE: you MUST run install-hooks.sh again when updating this file!

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
############ ############
# NOTE: you MUST run install-hooks.sh again when updating this file! # NOTE: you MUST run install-hooks.sh again when updating this file!

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# this has to run once atfer git clone # this has to run once atfer git clone
# and every time we create new hooks # and every time we create new hooks
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# magic to ensure that we're always inside the root of our application, # magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script # no matter from which directory we'll run script

View File

@ -2,7 +2,7 @@
# file: make-distribution.sh # file: make-distribution.sh
# creates files and arcchives to dirtribute bashbot # creates files and arcchives to dirtribute bashbot
# #
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# magic to ensure that we're always inside the root of our application, # magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script # no matter from which directory we'll run script

View File

@ -5,7 +5,7 @@
# If you your bot is finished you can use make-standalone.sh to create the # If you your bot is finished you can use make-standalone.sh to create the
# the old all-in-one bashbot: bashbot.sh and commands.sh only! # the old all-in-one bashbot: bashbot.sh and commands.sh only!
# #
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# magic to ensure that we're always inside the root of our application, # magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script # no matter from which directory we'll run script

View File

@ -1,3 +1,3 @@
# list of additional files to check from shellcheck # list of additional files to check from shellcheck
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
bashbot.rc bashbot.rc

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# #
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# shellcheck disable=SC2016 # shellcheck disable=SC2016
# #
# Easy Versioning in git: # Easy Versioning in git:

View File

@ -87,5 +87,5 @@ The old format is supported for backward compatibility, but may fail for corner
#### [Next Create Bot](1_firstbot.md) #### [Next Create Bot](1_firstbot.md)
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc

View File

@ -65,5 +65,5 @@ group. This step is up to you actually.
#### [Prev Installation](0_install.md) #### [Prev Installation](0_install.md)
#### [Next Getting started](2_usage.md) #### [Next Getting started](2_usage.md)
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc

View File

@ -182,5 +182,5 @@ send_action "${CHAT[ID]}" "action"
#### [Prev Create Bot](1_firstbot.md) #### [Prev Create Bot](1_firstbot.md)
#### [Next Advanced Usage](3_advanced.md) #### [Next Advanced Usage](3_advanced.md)
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc

View File

@ -180,5 +180,5 @@ See also [answer_inline_multi, answer_inline_compose](6_reference.md#answer_inli
#### [Prev Getting started](2_usage.md) #### [Prev Getting started](2_usage.md)
#### [Next Expert Use](4_expert.md) #### [Next Expert Use](4_expert.md)
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc

View File

@ -104,5 +104,5 @@ An example crontab is provided in ```examples/bashbot.cron```.
#### [Prev Expert Use](4_expert.md) #### [Prev Expert Use](4_expert.md)
#### [Next Best Practice](5_practice.md) #### [Next Best Practice](5_practice.md)
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc

View File

@ -153,5 +153,5 @@ The second warning is about an unused variable, this is true because in our exam
#### [Prev Best Practice](5_practice.md) #### [Prev Best Practice](5_practice.md)
#### [Next Functions Reference](6_reference.md) #### [Next Functions Reference](6_reference.md)
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc

View File

@ -681,5 +681,5 @@ The name of your bot is availible as bash variable "$ME", there is no need to ca
#### [Prev Best Practice](5_practice.md) #### [Prev Best Practice](5_practice.md)
#### [Next Notes for Developers](7_develop.md) #### [Next Notes for Developers](7_develop.md)
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc

View File

@ -188,5 +188,5 @@ fi
#### [Prev Function Reference](6_reference.md) #### [Prev Function Reference](6_reference.md)
#### [Next Bashbot Environment](8_custom.md) #### [Next Bashbot Environment](8_custom.md)
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc

View File

@ -131,5 +131,5 @@ for every poll until the maximum of BASHBOT_SLEEP ms.
#### [Prev Notes for Developers](7_develop.md) #### [Prev Notes for Developers](7_develop.md)
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc

View File

@ -55,6 +55,6 @@ convert existing bots.
**external-use** will contain some examples on how to send messages from external scripts to Telegram chats or users. **external-use** will contain some examples on how to send messages from external scripts to Telegram chats or users.
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc

View File

@ -4,7 +4,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# adjust your language setting here # adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -2,7 +2,7 @@
# file: run_filename # file: run_filename
# background job to display content of all new files in WATCHDIR # background job to display content of all new files in WATCHDIR
# #
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# adjust your language setting here # adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -2,7 +2,7 @@
# file: run_filename # file: run_filename
# background job to display all new files in WATCHDIR # background job to display all new files in WATCHDIR
# #
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# adjust your language setting here # adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -4,7 +4,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# adjust your language setting here # adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -2,7 +2,7 @@
# file. multibot.sh # file. multibot.sh
# description: run multiple telegram bots from one installation # description: run multiple telegram bots from one installation
# #
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then
echo "Usage: $0 botname command" echo "Usage: $0 botname command"

View File

@ -7,7 +7,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
SHELL=/bin/sh SHELL=/bin/sh

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# adjust your language setting here # adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -4,7 +4,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# adjust your language setting here # adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# adjust your language setting here # adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -1,7 +1,7 @@
# file: botacl # file: botacl
# a user not listed here, will return false from 'user_is_allowed' # a user not listed here, will return false from 'user_is_allowed'
# #
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# Format: # Format:
# user:ressource:chat # user:ressource:chat

View File

@ -5,7 +5,7 @@
# to show how you can customize bashbot by only editing mycommands.sh # to show how you can customize bashbot by only editing mycommands.sh
# NOTE: this is not tested, simply copied from original source and reworked! # NOTE: this is not tested, simply copied from original source and reworked!
# #
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# #
# shellcheck disable=SC2154 # shellcheck disable=SC2154
# shellcheck disable=SC2034 # shellcheck disable=SC2034

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# #
# source from commands.sh to use the aliases # source from commands.sh to use the aliases

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# source from commands.sh to use the inline functions # source from commands.sh to use the inline functions

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# source from commands.sh if you want ro use interactive or background jobs # 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. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# source from commands.sh to use the member functions # source from commands.sh to use the member functions

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# source from commands.sh to use the sendMessage functions # source from commands.sh to use the sendMessage functions

View File

@ -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.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# #
# uncomment the following lines to overwrite info and help messages # uncomment the following lines to overwrite info and help messages

View File

@ -2,7 +2,7 @@
# #
# ADD a new test skeleton to test dir, but does not activate test # ADD a new test skeleton to test dir, but does not activate test
# #
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# magic to ensure that we're always inside the root of our application, # magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script # no matter from which directory we'll run script

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# common variables # common variables
export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
../dev/hooks/pre-commit.sh ../dev/hooks/pre-commit.sh

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# file: b-example-test.sh # file: b-example-test.sh
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# include common functions and definitions # include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh # shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# include common functions and definitions # include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh # shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# include common functions and definitions # include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh # shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# include common functions and definitions # include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh # shellcheck source=test/ALL-tests.inc.sh
@ -20,8 +20,10 @@ get_file() {
} }
# get telegram input from file # get telegram input from file
export UPDATE export UPDATE UPD
UPDATE="$(cat "${INPUTFILE}")" UPDATE="$(cat "${INPUTFILE}")"
declare -A UPD
source <( printf 'UPD=( %s )' "$(sed <<<"${UPDATE}" -E -e 's/\t/=/g' -e 's/=(true|false)/="\1"/')" )
# run process_message with and without phyton # run process_message with and without phyton
echo "Check process_inline ..." echo "Check process_inline ..."

View File

@ -1,5 +1,5 @@
["ok"] true ["ok"] true
["result",0,"update_id"]i 1234567890 ["result",0,"update_id"] 1234567890
["result",0,"inline_query","id"] "987654321" ["result",0,"inline_query","id"] "987654321"
["result",0,"inline_query","query"] "message" ["result",0,"inline_query","query"] "message"
["result",0,"inline_query","from","id"] 123456789 ["result",0,"inline_query","from","id"] 123456789

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# include common functions and definitions # include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh # shellcheck source=test/ALL-tests.inc.sh
@ -20,8 +20,10 @@ get_file() {
} }
# get telegram input from file # get telegram input from file
export UPDATE export UPDATE UPD
UPDATE="$(cat "${INPUTFILE}")" UPDATE="$(cat "${INPUTFILE}")"
declare -A UPD
source <( printf 'UPD=( %s )' "$(sed <<<"${UPDATE}" -E -e 's/\t/=/g' -e 's/=(true|false)/="\1"/')" )
# run process_message # run process_message
echo "Check process_message ..." echo "Check process_message ..."

View File

@ -1,8 +1,7 @@
["ok"] true ["ok"] true
["result",0,"update_id"] 146860800 ["result",0,"update_id"] 146860800
["result",0,"message","message_id"] 6541 6541 # this is a cross check for JsonGetValue ["result",0,"message","message_id"] 6541
["result",0,"message","text"] "\ud83d\ude02\ud83d\ude1d\ud83d\udc4c\u263a\u2764\ud83d\ude15\ud83d\ude08#\u20e3\ud83c\udf0f\ud83c\udf89\ud83d\ude4a\ud83d\ude49\u2615\ud83d\ude80\u2708\ud83d\ude82\ud83d\udcaf\u2714\u303d\ud83d\udd1a" ["result",0,"message","text"] "\ud83d\ude02\ud83d\ude1d\ud83d\udc4c\u263a\u2764\ud83d\ude15\ud83d\ude08#\u20e3\ud83c\udf0f\ud83c\udf89\ud83d\ude4a\ud83d\ude49\u2615\ud83d\ude80\u2708\ud83d\ude82\ud83d\udcaf\u2714\u303d\ud83d\udd1a"
["result",0,"message","text"] "Cross check, this second text must be ignored"
["result",0,"message","from","id"] 123456789 ["result",0,"message","from","id"] 123456789
["result",0,"message","from","is_bot"] false ["result",0,"message","from","is_bot"] false
["result",0,"message","from","first_name"] "Kay" ["result",0,"message","from","first_name"] "Kay"
@ -89,5 +88,4 @@
["result",0,"message","contact","vcard"] "BEGIN:VCARD\nVERSION:2.1\nN:Pannenhilfe;ADAC;;;\nFN:ADAC Pannenhilfe\nTEL;CELL;PREF:+49179222222\nTEL;X-Mobil:222222\nEND:VCARD" ["result",0,"message","contact","vcard"] "BEGIN:VCARD\nVERSION:2.1\nN:Pannenhilfe;ADAC;;;\nFN:ADAC Pannenhilfe\nTEL;CELL;PREF:+49179222222\nTEL;X-Mobil:222222\nEND:VCARD"
["result",0,"message","voice","duration"] 2 ["result",0,"message","voice","duration"] 2
["result",0,"message","voice","mime_type"] "audio/ogg" ["result",0,"message","voice","mime_type"] "audio/ogg"
["result",0,"message","voice","file_id"] "AwADAgADOAQAAqd24Emnm_VGmmVEuAI"
["result",0,"message","voice","file_size"] 4262 ["result",0,"message","voice","file_size"] 4262

View File

@ -2,6 +2,7 @@ USER: FIRST_NAME Kay
USER: ID 123456789 USER: ID 123456789
USER: LAST_NAME M USER: LAST_NAME M
USER: USERNAME Gnadelwartz USER: USERNAME Gnadelwartz
CHAT: ALL_ADMIN
CHAT: ALL_MEMBERS_ARE_ADMINISTRATORS CHAT: ALL_MEMBERS_ARE_ADMINISTRATORS
CHAT: FIRST_NAME Test CHAT: FIRST_NAME Test
CHAT: ID 123456789 CHAT: ID 123456789

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# include common functions and definitions # include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh # shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# include common functions and definitions # include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh # shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.80-0-g5bce3f7 #### $$VERSION$$ v0.90-dev-0-g75691dc
# include common functions and definitions # include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh # shellcheck source=test/ALL-tests.inc.sh