fix old errors found while factor out send_message to module

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2019-05-13 11:24:42 +02:00
parent 92f022d038
commit e9cf8d25e5
12 changed files with 38 additions and 29 deletions

View File

@ -12,7 +12,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-dev2-6-g5b10e75
#### $$VERSION$$ v0.80-dev2-7-g92f022d
#
# Exit Codes:
# - 0 sucess (hopefully)
@ -385,11 +385,12 @@ else
local out="$1"
local remain=""
local regexp='(.*)\\u[dD]([0-9a-fA-F]{3})\\u[dD]([0-9a-fA-F]{3})(.*)'
local W1 W2 U
while [[ "${out}" =~ $regexp ]] ; do
# match 2 \udxxx hex values, calculate new U, then split and replace
local W1=$(( ( 0xd${BASH_REMATCH[2]} & 0x3ff) <<10 ))
local W2=$(( 0xd${BASH_REMATCH[3]} & 0x3ff ))
local U=$(( ( W1 | W2 ) + 0x10000 ))
W1=$(( ( 0xd${BASH_REMATCH[2]} & 0x3ff) <<10 ))
W2=$(( 0xd${BASH_REMATCH[3]} & 0x3ff ))
U=$(( ( W1 | W2 ) + 0x10000 ))
remain="$(printf '\\U%8.8x' "${U}")${BASH_REMATCH[4]}${remain}"
out="${BASH_REMATCH[1]}"
done

View File

@ -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-dev2-6-g5b10e75
#### $$VERSION$$ v0.80-dev2-7-g92f022d
#
# adjust your language setting here, e.g.when run from other user or cron.

View 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-dev2-2-g0c5e3dd
#### $$VERSION$$ v0.80-dev2-7-g92f022d
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script
@ -49,8 +49,8 @@ if [ "$fail" -eq 0 ]; then
else
/bin/echo -n 'FAILURE '
exitcode=1
rm -rf "${TESTENV}/test"
find "${TESTENV}/"* ! -name '[a-z]-*' -delete
#rm -rf "${TESTENV}/test"
#find "${TESTENV}/"* ! -name '[a-z]-*' -delete
fi
echo -e "${passed} / ${tests}\\n"

View File

@ -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-dev2-6-g5b10e75
#### $$VERSION$$ v0.80-dev2-7-g92f022d
# source from commands.sh to use the sendMessage functions
@ -90,7 +90,7 @@ send_file() {
local CAPTION
local chat_id=$1
local file=$2
echo "$file" | grep -qE "$FILE_REGEX" || return
[[ "$file" =~ $FILE_REGEX ]] || return
local ext="${file##*.}"
case $ext in
mp3|flac)

View File

@ -2,7 +2,7 @@
#
# ADD a new test skeleton to test dir, but does not activate test
#
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
#### $$VERSION$$ v0.80-dev2-7-g92f022d
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script
@ -65,6 +65,7 @@ cd "\${TESTDIR}" || exit 1
# source bashbot.sh function, uncomment if you want to test functions
# shellcheck source=./bashbot.sh
# source "\\${TESTDIR}/bashbot.sh" source
# source "\\${TESTDIR}/commands.sh" source
# start writing your tests here ...

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
#### $$VERSION$$ v0.80-dev2-7-g92f022d
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh
@ -36,6 +36,8 @@ cd "${TESTDIR}" || exit
# shellcheck source=./bashbot.sh
source "${TESTDIR}/bashbot.sh" source
source "${TESTDIR}/commands.sh" source
trap '' EXIT
cd "${DIRME}" || exit 1
echo "${SUCCESS}"

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
#### $$VERSION$$ v0.80-dev2-7-g92f022d
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh
@ -12,7 +12,7 @@ cd "${TESTDIR}" || exit 1
# shellcheck source=./bashbot.sh
source "${TESTDIR}/bashbot.sh" source
# shellcheck source=./bashbot.sh
source "${TESTDIR}/modules/inline.sh" source
source "${TESTDIR}/modules/answerInline.sh" source
# overwrite get_file for test
get_file() {

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
#### $$VERSION$$ v0.80-dev2-7-g92f022d
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh
@ -11,6 +11,8 @@ set -e
cd "${TESTDIR}" || exit 1
# shellcheck source=./bashbot.sh
source "${TESTDIR}/bashbot.sh" source
# shellcheck source=./bashbot.sh
source "${TESTDIR}/commands.sh" source
# overwrite get_file for test
get_file() {

View File

@ -1,34 +1,42 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
#### $$VERSION$$ v0.80-dev2-7-g92f022d
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh
source "./ALL-tests.inc.sh"
set -e
set +f
cd "${TESTDIR}" || exit 1
# source bashbot.sh function, uncomment if you want to test functions
# shellcheck source=./bashbot.sh
source "${TESTDIR}/bashbot.sh" source
source "${TESTDIR}/modules/background.sh"
# shellcheck source=./bashbot.sh
source "${TESTDIR}/commands.sh" source
_is_function send_message || echo "Send Message not found!"
# start writing your tests here ...
# over write sendJson to output parameter only
sendEmpty() {
printf 'chat:%s\tJSON:%s\nURL:%s\n\n' "${1}" "${2}" "${3}"
}
sendJson() {
printf 'chat:%s\tJSON:%s\nURL:%s\n\n' "${1}" "${2}" "${3}"
}
# send text input to send_message
#set -x
echo -n " Send line ..."
while IFS='' read -r line || [[ -n "$line" ]]; do
while read -r line ; do
echo -n "."
send_message "123456" "$line" >>"${OUTPUTFILE}"
done < "${INPUTFILE}" 2>>"${LOGFILE}"
done < "${INPUTFILE}" #2>>"${LOGFILE}"
echo " done."
{ diff -c "${REFFILE}" "${OUTPUTFILE}" || exit 1; } | cat -v

View File

@ -8,10 +8,8 @@ markdown_parse_mode This is a *MARKDOWN* text mynewlinestartshere with a line br
# test for keyboard, file, venue output
Text plus keyboard will appear in chat mykeyboardstartshere [ "Yep, sure" , "No, highly unlikely" ]
Text plus file will appear in chat myfilelocationstartshere /home/user/doge.jpg
Text plus location will appear in chat mylatstartshere la10 mylongstartshere lo20
Text plus vuene will appear in chat mylatstartshere la10 mylongstartshere lo20 mytitlestartshere my home myaddressstartshere Diagon Alley N. 37
All in one will appear in chat mykeyboardstartshere [ "Yep, sure" , "No, highly unlikely" ] myfilelocationstartshere /home/user/doge.jpg mylatstartshere la10 mylongstartshere lo20
# test for new inline button
Text plus keyboard will appear in chat mybtextstartshere Button Text myburlstartshere https://www...

View File

@ -28,9 +28,6 @@ URL:https://api.telegram.org/botbashbottestscript/sendMessage
chat:123456 JSON:"text":"Text plus keyboard will appear in chat", "reply_markup": {"keyboard": [ [ "Yep, sure" , "No, highly unlikely" ] ] , "one_time_keyboard":true}
URL:https://api.telegram.org/botbashbottestscript/sendMessage
chat:123456 JSON:"action": "upload_photo"
URL:https://api.telegram.org/botbashbottestscript/sendChatAction
chat:123456 JSON:"latitude": la10, "longitude": lo20
URL:https://api.telegram.org/botbashbottestscript/sendLocation
@ -40,9 +37,6 @@ URL:https://api.telegram.org/botbashbottestscript/sendVenue
chat:123456 JSON:"text":"All in one will appear in chat", "reply_markup": {"keyboard": [ [ "Yep, sure" , "No, highly unlikely" ] ] , "one_time_keyboard":true}
URL:https://api.telegram.org/botbashbottestscript/sendMessage
chat:123456 JSON:"action": "upload_photo"
URL:https://api.telegram.org/botbashbottestscript/sendChatAction
chat:123456 JSON:"latitude": la10, "longitude": lo20
URL:https://api.telegram.org/botbashbottestscript/sendLocation

View File

@ -1,17 +1,20 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
#### $$VERSION$$ v0.80-dev2-7-g92f022d
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh
source "./ALL-tests.inc.sh"
set -e
set +f
cd "${TESTDIR}" || exit 1
# source bashbot.sh function, uncomment if you want to test functions
# shellcheck source=./bashbot.sh
source "${TESTDIR}/bashbot.sh" source
# shellcheck source=./bashbot.sh
source "${TESTDIR}/commands.sh" source
# start writing your tests here ...