some minor adjustments in bashbot.sh

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2019-06-01 12:41:12 +02:00
parent 274f5d84ad
commit 9a81e440f1
4 changed files with 12 additions and 16 deletions

View File

@ -93,7 +93,8 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
</ul></li>
<li><a href="doc/5_practice.md">Best Practices</a>
<ul>
<li>Customize commands.sh</li>
<li>Customize mycommands.sh</li>
<li>Overwrite/disable commands</li>
<li>Seperate logic from commands</li>
<li>Test your Bot with shellcheck</li>
</ul></li>
@ -186,6 +187,6 @@ It features background tasks and interactive chats, and can serve as an interfac
<p><span class="citation">@Gnadelwartz</span></p>
<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>
<h4 id="version-v0.90-0-g7029f7f"><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-0-g7029f7f</h4>
<h4 id="version-v0.90-1-g5ebfacc"><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-1-g5ebfacc</h4>
</body>
</html>

View File

@ -180,4 +180,4 @@ This may happen if to many wrong requests are sent to api.telegram.org, e.g. usi
If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
#### $$VERSION$$ v0.90-0-g7029f7f
#### $$VERSION$$ v0.90-1-g5ebfacc

View File

@ -53,7 +53,8 @@ availible on www.github.com
* Use from CLI and Scripts
* Customize Bashbot Environment
* [Best Practices](doc/5_practice.md)
* Customize commands.sh
* Customize mycommands.sh
* Overwrite/disable commands
* Seperate logic from commands
* Test your Bot with shellcheck
* [Function Reference](doc/6_reference.md)
@ -252,4 +253,4 @@ tor proxy on your server you may uncomment the ```BASHBOT_CURL_ARGS``` line in
If you feel that there's something missing or if you found a bug, feel free to
submit a pull request!
#### $$VERSION$$ v0.90-0-g7029f7f
#### $$VERSION$$ v0.90-1-g5ebfacc

View File

@ -11,7 +11,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.90-0-g7029f7f
#### $$VERSION$$ v0.90-2-g274f5d8
#
# Exit Codes:
# - 0 sucess (hopefully)
@ -348,11 +348,10 @@ process_client() {
local num="$1" debug="$2"
CMD=( ); iQUERY=( )
iQUERY[ID]="${UPD["result",${num},"inline_query","id"]}"
[[ "${debug}" = *"debug"* ]] && cat <<< "$UPDATE" >>"MESSAGE.log"
if [ "${iQUERY[ID]}" = "" ]; then
[[ "${debug}" = *"debug"* ]] && cat <<< "$UPDATE" >>"MESSAGE.log"
process_message "${num}" "${debug}"
else
[[ "${debug}" = *"debug"* ]] && cat <<< "$UPDATE" >>"INLINE.log"
process_inline "${num}" "${debug}"
fi
#####
@ -387,13 +386,12 @@ start_timer(){
EVENT_TIMER="0"
event_timer() {
local event timer debug="$1"
(( EVENT_TIMER += 1 ))
(( EVENT_TIMER++ ))
# shellcheck disable=SC2153
for event in "${!BASHBOT_EVENT_TIMER[@]}"
do
timer="${event##*,}"
[[ ! "$timer" =~ ^-*[0-9]+$ ]] && continue
[[ "$timer" =~ ^-*0+$ ]] && continue
[[ ! "$timer" =~ ^-*[1-9][0-9]*$ ]] && continue
if [ "$(( EVENT_TIMER % timer ))" = "0" ]; then
_exec_if_function "${BASHBOT_EVENT_TIMER[${event}]}" "timer" "${debug}"
[ "$(( EVENT_TIMER % timer ))" -lt "0" ] && \
@ -492,7 +490,6 @@ process_inline() {
iQUERY[FIRST_NAME]="$(JsonDecode "${UPD["result",${num},"inline_query","from","first_name"]}")"
iQUERY[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"inline_query","from","last_name"]}")"
iQUERY[USERNAME]="$(JsonDecode "${UPD["result",${num},"inline_query","from","username"]}")"
# event_inline &
}
process_message() {
local num="$1"
@ -538,7 +535,6 @@ process_message() {
fi
# Audio
URLS=( )
URLS[AUDIO]="$(get_file "${UPD["result",${num},"message","audio","file_id"]}")"
# Document
URLS[DOCUMENT]="$(get_file "${UPD["result",${num},"message","document","file_id"]}")"
@ -575,19 +571,17 @@ process_message() {
CAPTION="$(JsonDecode "${UPD["result",${num},"message","caption"]}")"
# Location
LOCATION=( )
LOCATION[LONGITUDE]="${UPD["result",${num},"message","location","longitude"]}"
LOCATION[LATITUDE]="${UPD["result",${num},"message","location","latitude"]}"
# split message in command and args
CMD=( )
if [[ "${MESSAGE[0]}" = "/"* ]]; then
set -f; unset IFS
# shellcheck disable=SC2206
CMD=( ${MESSAGE[0]} )
CMD[0]="${CMD[0]%%@*}"
set +f
else
CMD[0]=""
fi
}