start 0.90-dev - convert to array
This commit is contained in:
parent
75691dc685
commit
5e6d62f19f
|
@ -108,6 +108,6 @@
|
|||
<p><span class="citation">@Gnadelwartz</span></p>
|
||||
<h2 id="thats-it">That’s it!</h2>
|
||||
<p>If you feel that there’s 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>
|
||||
</html>
|
||||
|
|
|
@ -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!
|
||||
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
|
|
@ -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
|
||||
submit a pull request!
|
||||
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
# description: Start or stop telegram-bash-bot
|
||||
#
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
# shellcheck disable=SC2009
|
||||
# shellcheck disable=SC2181
|
||||
|
||||
|
|
109
bashbot.sh
109
bashbot.sh
|
@ -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.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
#
|
||||
# Exit Codes:
|
||||
# - 0 sucess (hopefully)
|
||||
|
@ -20,6 +20,7 @@
|
|||
# - 3 user / command / file not found
|
||||
# - 4 unkown command
|
||||
# - 5 cannot connect to telegram bot
|
||||
# shellcheck disable=SC2140
|
||||
|
||||
# are we runnig in a terminal?
|
||||
if [ -t 1 ] && [ "$TERM" != "" ]; then
|
||||
|
@ -115,8 +116,8 @@ UPD_URL=$URL'/getUpdates?offset='
|
|||
GETFILE_URL=$URL'/getFile'
|
||||
|
||||
unset USER
|
||||
declare -A 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
|
||||
declare -A UPD BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE iQUERY
|
||||
export res UPD BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE iQUERY CAPTION
|
||||
|
||||
COMMANDS="${BASHBOT_ETC:-.}/commands.sh"
|
||||
if [ "$1" != "source" ]; then
|
||||
|
@ -282,13 +283,15 @@ JsonGetValue() {
|
|||
process_updates() {
|
||||
local max num debug="$1"
|
||||
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
|
||||
process_client "$num" "${debug}"
|
||||
done
|
||||
}
|
||||
process_client() {
|
||||
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
|
||||
[[ "${debug}" = *"debug"* ]] && cat <<< "$UPDATE" >>"MESSAGE.log"
|
||||
process_message "${num}" "${debug}"
|
||||
|
@ -304,92 +307,90 @@ process_client() {
|
|||
}
|
||||
process_inline() {
|
||||
local num="${1}"
|
||||
iQUERY[0]="$(JsonDecode "$(JsonGetString <<<"${UPDATE}" '"result",0,"inline_query","query"')")"
|
||||
iQUERY[USER_ID]="$(JsonGetValue <<<"${UPDATE}" '"result",'"${num}"',"inline_query","from","id"')"
|
||||
iQUERY[FIRST_NAME]="$(JsonDecode "$(JsonGetString <<<"${UPDATE}" '"result",'"${num}"',"inline_query","from","first_name"')")"
|
||||
iQUERY[LAST_NAME]="$(JsonDecode "$(JsonGetString <<<"${UPDATE}" '"result",'"${num}"',"inline_query","from","last_name"')")"
|
||||
iQUERY[USERNAME]="$(JsonDecode "$(JsonGetString <<<"${UPDATE}" '"result",'"${num}"',"inline_query","from","username"')")"
|
||||
iQUERY[0]="$(JsonDecode "${UPD["result",${num},"inline_query","query"]}")"
|
||||
iQUERY[USER_ID]="${UPD["result",${num},"inline_query","from","id"]}"
|
||||
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"]}")"
|
||||
}
|
||||
process_message() {
|
||||
local num="$1"
|
||||
local TMP="${TMPDIR:-.}/$RANDOM$RANDOM-MESSAGE"
|
||||
cat <<< "$UPDATE" >"$TMP"
|
||||
# Message
|
||||
MESSAGE[0]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","text"' <"$TMP")" | sed 's#\\/#/#g')"
|
||||
MESSAGE[ID]="$(JsonGetValue '"result",'"${num}"',"message","message_id"' <"$TMP" )"
|
||||
MESSAGE[0]="$(JsonDecode "${UPD["result",${num},"message","text"]}" | sed 's#\\/#/#g')"
|
||||
MESSAGE[ID]="${UPD["result",${num},"message","message_id"]}"
|
||||
|
||||
# Chat
|
||||
CHAT[ID]="$(JsonGetValue '"result",'"${num}"',"message","chat","id"' <"$TMP" )"
|
||||
CHAT[FIRST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","chat","first_name"' <"$TMP")")"
|
||||
CHAT[LAST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","chat","last_name"' <"$TMP")")"
|
||||
CHAT[USERNAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","chat","username"' <"$TMP")")"
|
||||
CHAT[TITLE]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","chat","title"' <"$TMP")")"
|
||||
CHAT[TYPE]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","chat","type"' <"$TMP")")"
|
||||
CHAT[ALL_MEMBERS_ARE_ADMINISTRATORS]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","chat","all_members_are_administrators"' <"$TMP")")"
|
||||
CHAT[ID]="${UPD["result",${num},"message","chat","id"]}"
|
||||
CHAT[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"message","chat","last_name"]}")"
|
||||
CHAT[FIRST_NAME]="$(JsonDecode "${UPD["result",${num},"message","chat","first_name"]}")"
|
||||
CHAT[USERNAME]="$(JsonDecode "${UPD["result",${num},"message","chat","username"]}")"
|
||||
CHAT[TITLE]="$(JsonDecode "${UPD["result",${num},"message","chat","title"]}")"
|
||||
CHAT[TYPE]="$(JsonDecode "${UPD["result",${num},"message","chat","type"]}")"
|
||||
CHAT[ALL_ADMIN]="${UPD["result",${num},"message","chat","all_members_are_administrators"]}"
|
||||
CHAT[ALL_MEMBERS_ARE_ADMINISTRATORS]="${CHAT[ALL_ADMIN]}" # backward compatibility
|
||||
|
||||
# User
|
||||
USER[ID]="$(JsonGetValue '"result",'"${num}"',"message","from","id"' <"$TMP" )"
|
||||
USER[FIRST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","from","first_name"' <"$TMP")")"
|
||||
USER[LAST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","from","last_name"' <"$TMP")")"
|
||||
USER[USERNAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","from","username"' <"$TMP")")"
|
||||
USER[ID]="${UPD["result",${num},"message","from","id"]}"
|
||||
USER[FIRST_NAME]="$(JsonDecode "${UPD["result",${num},"message","from","first_name"]}")"
|
||||
USER[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"message","from","last_name"]}")"
|
||||
USER[USERNAME]="$(JsonDecode "${UPD["result",${num},"message","from","username"]}")"
|
||||
|
||||
# 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
|
||||
REPLYTO[0]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","reply_to_message","text"' <"$TMP")")"
|
||||
REPLYTO[ID]="$(JsonGetValue '"result",'"${num}"',"message","reply_to_message","message_id"' <"$TMP")"
|
||||
REPLYTO[FIRST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","reply_to_message","from","first_name"' <"$TMP")")"
|
||||
REPLYTO[LAST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","reply_to_message","from","last_name"' <"$TMP")")"
|
||||
REPLYTO[USERNAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","reply_to_message","from","username"' <"$TMP")")"
|
||||
REPLYTO[0]="$(JsonDecode "${UPD["result",${num},"message","reply_to_message","text"]}")"
|
||||
REPLYTO[ID]="${UPD["result",${num},"message","reply_to_message","message_id"]}"
|
||||
REPLYTO[FIRST_NAME]="$(JsonDecode "${UPD["result",${num},"message","reply_to_message","from","first_name"]}")"
|
||||
REPLYTO[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"message","reply_to_message","from","last_name"]}")"
|
||||
REPLYTO[USERNAME]="$(JsonDecode "${UPD["result",${num},"message","reply_to_message","from","username"]}")"
|
||||
fi
|
||||
|
||||
# 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
|
||||
FORWARD[ID]="${MESSAGE[ID]}" # same as message ID
|
||||
FORWARD[FIRST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","forward_from","first_name"' <"$TMP")")"
|
||||
FORWARD[LAST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","forward_from","last_name"' <"$TMP")")"
|
||||
FORWARD[USERNAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","forward_from","username"' <"$TMP")")"
|
||||
FORWARD[FIRST_NAME]="$(JsonDecode "${UPD["result",${num},"message","forward_from","first_name"]}")"
|
||||
FORWARD[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"message","forward_from","last_name"]}")"
|
||||
FORWARD[USERNAME]="$(JsonDecode "${UPD["result",${num},"message","forward_from","username"]}")"
|
||||
fi
|
||||
|
||||
# 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
|
||||
URLS[DOCUMENT]="$(get_file "$(JsonGetString '"result",'"${num}"',"message","document","file_id"' <"$TMP")")"
|
||||
URLS[DOCUMENT]="$(get_file "${UPD["result",${num},"message","document","file_id"]}")"
|
||||
# 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
|
||||
URLS[STICKER]="$(get_file "$(JsonGetString '"result",'"${num}"',"message","sticker","file_id"' <"$TMP")")"
|
||||
URLS[STICKER]="$(get_file "${UPD["result",${num},"message","sticker","file_id"]}")"
|
||||
# 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
|
||||
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[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
|
||||
CONTACT[USER_ID]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","contact","user_id"' <"$TMP")")"
|
||||
CONTACT[LAST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","contact","last_name"' <"$TMP")")"
|
||||
CONTACT[NUMBER]="$(JsonGetString '"result",'"${num}"',"message","contact","phone_number"' <"$TMP")"
|
||||
CONTACT[VCARD]="$(JsonGetString '"result",'"${num}"',"message","contact","vcard"' <"$TMP")"
|
||||
CONTACT[USER_ID]="$(JsonDecode "${UPD["result",${num},"message","contact","user_id"]}")"
|
||||
CONTACT[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"message","contact","last_name"]}")"
|
||||
CONTACT[NUMBER]="${UPD["result",${num},"message","contact","phone_number"]}"
|
||||
CONTACT[VCARD]="$(JsonGetString '"result",'"${num}"',"message","contact","vcard"' <<<"${UPDATE}")"
|
||||
fi
|
||||
|
||||
# vunue
|
||||
VENUE[TITLE]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","venue","title"' <"$TMP")")"
|
||||
VENUE[TITLE]="$(JsonDecode "${UPD["result",${num},"message","venue","title"]}")"
|
||||
if [ "${VENUE[TITLE]}" != "" ]; then
|
||||
VENUE[ADDRESS]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","venue","address"' <"$TMP")")"
|
||||
VENUE[LONGITUDE]="$(JsonGetValue '"result",'"${num}"',"message","venue","location","longitude"' <"$TMP")"
|
||||
VENUE[LATITUDE]="$(JsonGetValue '"result",'"${num}"',"message","venue","location","latitude"' <"$TMP")"
|
||||
VENUE[FOURSQUARE]="$(JsonGetString '"result",'"${num}"',"message","venue","foursquare_id"' <"$TMP")"
|
||||
VENUE[ADDRESS]="$(JsonDecode "${UPD["result",${num},"message","venue","address"]}")"
|
||||
VENUE[LONGITUDE]="${UPD["result",${num},"message","venue","location","longitude"]}"
|
||||
VENUE[LATITUDE]="${UPD["result",${num},"message","venue","location","latitude"]}"
|
||||
VENUE[FOURSQUARE]="${UPD["result",${num},"message","venue","foursquare_id"]}"
|
||||
fi
|
||||
|
||||
# Caption
|
||||
CAPTION="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","caption"' <"$TMP")")"
|
||||
CAPTION="$(JsonDecode "${UPD["result",${num},"message","caption"]}")"
|
||||
|
||||
# Location
|
||||
LOCATION[LONGITUDE]="$(JsonGetValue '"result",'"${num}"',"message","location","longitude"' <"$TMP")"
|
||||
LOCATION[LATITUDE]="$(JsonGetValue '"result",'"${num}"',"message","location","latitude"' <"$TMP")"
|
||||
rm "$TMP"
|
||||
LOCATION[LONGITUDE]="${UPD["result",${num},"message","location","longitude"]}"
|
||||
LOCATION[LATITUDE]="${UPD["result",${num},"message","location","latitude"]}"
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
#
|
||||
|
||||
# adjust your language setting here, e.g.when run from other user or cron.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# this has to run once atfer git clone
|
||||
# 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,
|
||||
# no matter from which directory we'll run script
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# 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,
|
||||
# no matter from which directory we'll run script
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/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!
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/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!
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# this has to run once atfer git clone
|
||||
# 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,
|
||||
# no matter from which directory we'll run script
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# file: make-distribution.sh
|
||||
# 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,
|
||||
# no matter from which directory we'll run script
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# 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!
|
||||
#
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# magic to ensure that we're always inside the root of our application,
|
||||
# no matter from which directory we'll run script
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
# list of additional files to check from shellcheck
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
bashbot.rc
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
# shellcheck disable=SC2016
|
||||
#
|
||||
# Easy Versioning in git:
|
||||
|
|
|
@ -87,5 +87,5 @@ The old format is supported for backward compatibility, but may fail for corner
|
|||
|
||||
#### [Next Create Bot](1_firstbot.md)
|
||||
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
|
|
|
@ -65,5 +65,5 @@ group. This step is up to you actually.
|
|||
#### [Prev Installation](0_install.md)
|
||||
#### [Next Getting started](2_usage.md)
|
||||
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
|
|
|
@ -182,5 +182,5 @@ send_action "${CHAT[ID]}" "action"
|
|||
#### [Prev Create Bot](1_firstbot.md)
|
||||
#### [Next Advanced Usage](3_advanced.md)
|
||||
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
|
|
|
@ -180,5 +180,5 @@ See also [answer_inline_multi, answer_inline_compose](6_reference.md#answer_inli
|
|||
#### [Prev Getting started](2_usage.md)
|
||||
#### [Next Expert Use](4_expert.md)
|
||||
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
|
|
|
@ -104,5 +104,5 @@ An example crontab is provided in ```examples/bashbot.cron```.
|
|||
#### [Prev Expert Use](4_expert.md)
|
||||
#### [Next Best Practice](5_practice.md)
|
||||
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
|
|
|
@ -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)
|
||||
#### [Next Functions Reference](6_reference.md)
|
||||
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
|
|
|
@ -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)
|
||||
#### [Next Notes for Developers](7_develop.md)
|
||||
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
|
|
|
@ -188,5 +188,5 @@ fi
|
|||
#### [Prev Function Reference](6_reference.md)
|
||||
#### [Next Bashbot Environment](8_custom.md)
|
||||
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
|
|
|
@ -131,5 +131,5 @@ for every poll until the maximum of BASHBOT_SLEEP ms.
|
|||
|
||||
#### [Prev Notes for Developers](7_develop.md)
|
||||
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,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.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# adjust your language setting here
|
||||
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# file: run_filename
|
||||
# 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
|
||||
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# file: run_filename
|
||||
# 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
|
||||
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
||||
|
|
|
@ -4,7 +4,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.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# adjust your language setting here
|
||||
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# file. multibot.sh
|
||||
# description: run multiple telegram bots from one installation
|
||||
#
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then
|
||||
echo "Usage: $0 botname command"
|
||||
|
|
|
@ -7,7 +7,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.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
|
||||
SHELL=/bin/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.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# adjust your language setting here
|
||||
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
||||
|
|
|
@ -4,7 +4,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.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# adjust your language setting here
|
||||
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
||||
|
|
|
@ -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.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# adjust your language setting here
|
||||
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# file: botacl
|
||||
# a user not listed here, will return false from 'user_is_allowed'
|
||||
#
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
# Format:
|
||||
# user:ressource:chat
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# to show how you can customize bashbot by only editing mycommands.sh
|
||||
# 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=SC2034
|
||||
|
|
|
@ -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.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
#
|
||||
# source from commands.sh to use the aliases
|
||||
|
||||
|
|
|
@ -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.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# source from commands.sh to use the inline functions
|
||||
|
||||
|
|
|
@ -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.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# 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.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# source from commands.sh to use the member functions
|
||||
|
||||
|
|
|
@ -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.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# source from commands.sh to use the sendMessage functions
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# files: mycommands.sh.dist
|
||||
# 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
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# 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,
|
||||
# no matter from which directory we'll run script
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# common variables
|
||||
export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
../dev/hooks/pre-commit.sh
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
# file: b-example-test.sh
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
@ -20,8 +20,10 @@ get_file() {
|
|||
}
|
||||
|
||||
# get telegram input from file
|
||||
export UPDATE
|
||||
export UPDATE UPD
|
||||
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
|
||||
echo "Check process_inline ..."
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
["ok"] true
|
||||
["result",0,"update_id"]i 1234567890
|
||||
["ok"] true
|
||||
["result",0,"update_id"] 1234567890
|
||||
["result",0,"inline_query","id"] "987654321"
|
||||
["result",0,"inline_query","query"] "message"
|
||||
["result",0,"inline_query","from","id"] 123456789
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
@ -20,8 +20,10 @@ get_file() {
|
|||
}
|
||||
|
||||
# get telegram input from file
|
||||
export UPDATE
|
||||
export UPDATE UPD
|
||||
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
|
||||
echo "Check process_message ..."
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
["ok"] true
|
||||
["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"] "Cross check, this second text must be ignored"
|
||||
["result",0,"message","from","id"] 123456789
|
||||
["result",0,"message","from","is_bot"] false
|
||||
["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","voice","duration"] 2
|
||||
["result",0,"message","voice","mime_type"] "audio/ogg"
|
||||
["result",0,"message","voice","file_id"] "AwADAgADOAQAAqd24Emnm_VGmmVEuAI"
|
||||
["result",0,"message","voice","file_size"] 4262
|
||||
|
|
|
@ -2,6 +2,7 @@ USER: FIRST_NAME Kay
|
|||
USER: ID 123456789
|
||||
USER: LAST_NAME M
|
||||
USER: USERNAME Gnadelwartz
|
||||
CHAT: ALL_ADMIN
|
||||
CHAT: ALL_MEMBERS_ARE_ADMINISTRATORS
|
||||
CHAT: FIRST_NAME Test
|
||||
CHAT: ID 123456789
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.80-0-g5bce3f7
|
||||
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
|
Loading…
Reference in New Issue