mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-25 16:57:33 +00:00
fix old errors found while factor out send_message to module
This commit is contained in:
parent
92f022d038
commit
e9cf8d25e5
@ -12,7 +12,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-dev2-6-g5b10e75
|
#### $$VERSION$$ v0.80-dev2-7-g92f022d
|
||||||
#
|
#
|
||||||
# Exit Codes:
|
# Exit Codes:
|
||||||
# - 0 sucess (hopefully)
|
# - 0 sucess (hopefully)
|
||||||
@ -385,11 +385,12 @@ else
|
|||||||
local out="$1"
|
local out="$1"
|
||||||
local remain=""
|
local remain=""
|
||||||
local regexp='(.*)\\u[dD]([0-9a-fA-F]{3})\\u[dD]([0-9a-fA-F]{3})(.*)'
|
local regexp='(.*)\\u[dD]([0-9a-fA-F]{3})\\u[dD]([0-9a-fA-F]{3})(.*)'
|
||||||
|
local W1 W2 U
|
||||||
while [[ "${out}" =~ $regexp ]] ; do
|
while [[ "${out}" =~ $regexp ]] ; do
|
||||||
# match 2 \udxxx hex values, calculate new U, then split and replace
|
# match 2 \udxxx hex values, calculate new U, then split and replace
|
||||||
local W1=$(( ( 0xd${BASH_REMATCH[2]} & 0x3ff) <<10 ))
|
W1=$(( ( 0xd${BASH_REMATCH[2]} & 0x3ff) <<10 ))
|
||||||
local W2=$(( 0xd${BASH_REMATCH[3]} & 0x3ff ))
|
W2=$(( 0xd${BASH_REMATCH[3]} & 0x3ff ))
|
||||||
local U=$(( ( W1 | W2 ) + 0x10000 ))
|
U=$(( ( W1 | W2 ) + 0x10000 ))
|
||||||
remain="$(printf '\\U%8.8x' "${U}")${BASH_REMATCH[4]}${remain}"
|
remain="$(printf '\\U%8.8x' "${U}")${BASH_REMATCH[4]}${remain}"
|
||||||
out="${BASH_REMATCH[1]}"
|
out="${BASH_REMATCH[1]}"
|
||||||
done
|
done
|
||||||
|
@ -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-dev2-6-g5b10e75
|
#### $$VERSION$$ v0.80-dev2-7-g92f022d
|
||||||
#
|
#
|
||||||
|
|
||||||
# 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.
|
||||||
|
@ -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-dev2-2-g0c5e3dd
|
#### $$VERSION$$ v0.80-dev2-7-g92f022d
|
||||||
|
|
||||||
# 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
|
||||||
@ -49,8 +49,8 @@ if [ "$fail" -eq 0 ]; then
|
|||||||
else
|
else
|
||||||
/bin/echo -n 'FAILURE '
|
/bin/echo -n 'FAILURE '
|
||||||
exitcode=1
|
exitcode=1
|
||||||
rm -rf "${TESTENV}/test"
|
#rm -rf "${TESTENV}/test"
|
||||||
find "${TESTENV}/"* ! -name '[a-z]-*' -delete
|
#find "${TESTENV}/"* ! -name '[a-z]-*' -delete
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "${passed} / ${tests}\\n"
|
echo -e "${passed} / ${tests}\\n"
|
||||||
|
@ -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-dev2-6-g5b10e75
|
#### $$VERSION$$ v0.80-dev2-7-g92f022d
|
||||||
|
|
||||||
# source from commands.sh to use the sendMessage functions
|
# source from commands.sh to use the sendMessage functions
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ send_file() {
|
|||||||
local CAPTION
|
local CAPTION
|
||||||
local chat_id=$1
|
local chat_id=$1
|
||||||
local file=$2
|
local file=$2
|
||||||
echo "$file" | grep -qE "$FILE_REGEX" || return
|
[[ "$file" =~ $FILE_REGEX ]] || return
|
||||||
local ext="${file##*.}"
|
local ext="${file##*.}"
|
||||||
case $ext in
|
case $ext in
|
||||||
mp3|flac)
|
mp3|flac)
|
||||||
|
@ -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-dev2-1-g0b36bc5
|
#### $$VERSION$$ v0.80-dev2-7-g92f022d
|
||||||
|
|
||||||
# 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
|
||||||
@ -65,6 +65,7 @@ cd "\${TESTDIR}" || exit 1
|
|||||||
# source bashbot.sh function, uncomment if you want to test functions
|
# source bashbot.sh function, uncomment if you want to test functions
|
||||||
# shellcheck source=./bashbot.sh
|
# shellcheck source=./bashbot.sh
|
||||||
# source "\\${TESTDIR}/bashbot.sh" source
|
# source "\\${TESTDIR}/bashbot.sh" source
|
||||||
|
# source "\\${TESTDIR}/commands.sh" source
|
||||||
|
|
||||||
# start writing your tests here ...
|
# start writing your tests here ...
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
|
#### $$VERSION$$ v0.80-dev2-7-g92f022d
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
@ -36,6 +36,8 @@ cd "${TESTDIR}" || exit
|
|||||||
|
|
||||||
# shellcheck source=./bashbot.sh
|
# shellcheck source=./bashbot.sh
|
||||||
source "${TESTDIR}/bashbot.sh" source
|
source "${TESTDIR}/bashbot.sh" source
|
||||||
|
source "${TESTDIR}/commands.sh" source
|
||||||
|
|
||||||
trap '' EXIT
|
trap '' EXIT
|
||||||
cd "${DIRME}" || exit 1
|
cd "${DIRME}" || exit 1
|
||||||
echo "${SUCCESS}"
|
echo "${SUCCESS}"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
|
#### $$VERSION$$ v0.80-dev2-7-g92f022d
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
@ -12,7 +12,7 @@ cd "${TESTDIR}" || exit 1
|
|||||||
# shellcheck source=./bashbot.sh
|
# shellcheck source=./bashbot.sh
|
||||||
source "${TESTDIR}/bashbot.sh" source
|
source "${TESTDIR}/bashbot.sh" source
|
||||||
# shellcheck source=./bashbot.sh
|
# shellcheck source=./bashbot.sh
|
||||||
source "${TESTDIR}/modules/inline.sh" source
|
source "${TESTDIR}/modules/answerInline.sh" source
|
||||||
|
|
||||||
# overwrite get_file for test
|
# overwrite get_file for test
|
||||||
get_file() {
|
get_file() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
|
#### $$VERSION$$ v0.80-dev2-7-g92f022d
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
@ -11,6 +11,8 @@ set -e
|
|||||||
cd "${TESTDIR}" || exit 1
|
cd "${TESTDIR}" || exit 1
|
||||||
# shellcheck source=./bashbot.sh
|
# shellcheck source=./bashbot.sh
|
||||||
source "${TESTDIR}/bashbot.sh" source
|
source "${TESTDIR}/bashbot.sh" source
|
||||||
|
# shellcheck source=./bashbot.sh
|
||||||
|
source "${TESTDIR}/commands.sh" source
|
||||||
|
|
||||||
# overwrite get_file for test
|
# overwrite get_file for test
|
||||||
get_file() {
|
get_file() {
|
||||||
|
@ -1,34 +1,42 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
|
#### $$VERSION$$ v0.80-dev2-7-g92f022d
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
source "./ALL-tests.inc.sh"
|
source "./ALL-tests.inc.sh"
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
set +f
|
||||||
|
|
||||||
cd "${TESTDIR}" || exit 1
|
cd "${TESTDIR}" || exit 1
|
||||||
|
|
||||||
# source bashbot.sh function, uncomment if you want to test functions
|
# source bashbot.sh function, uncomment if you want to test functions
|
||||||
# shellcheck source=./bashbot.sh
|
# shellcheck source=./bashbot.sh
|
||||||
source "${TESTDIR}/bashbot.sh" source
|
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 ...
|
# start writing your tests here ...
|
||||||
|
|
||||||
# over write sendJson to output parameter only
|
# over write sendJson to output parameter only
|
||||||
|
sendEmpty() {
|
||||||
|
printf 'chat:%s\tJSON:%s\nURL:%s\n\n' "${1}" "${2}" "${3}"
|
||||||
|
}
|
||||||
|
|
||||||
sendJson() {
|
sendJson() {
|
||||||
printf 'chat:%s\tJSON:%s\nURL:%s\n\n' "${1}" "${2}" "${3}"
|
printf 'chat:%s\tJSON:%s\nURL:%s\n\n' "${1}" "${2}" "${3}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# send text input to send_message
|
# send text input to send_message
|
||||||
|
|
||||||
#set -x
|
|
||||||
echo -n " Send line ..."
|
echo -n " Send line ..."
|
||||||
while IFS='' read -r line || [[ -n "$line" ]]; do
|
|
||||||
|
while read -r line ; do
|
||||||
echo -n "."
|
echo -n "."
|
||||||
send_message "123456" "$line" >>"${OUTPUTFILE}"
|
send_message "123456" "$line" >>"${OUTPUTFILE}"
|
||||||
done < "${INPUTFILE}" 2>>"${LOGFILE}"
|
done < "${INPUTFILE}" #2>>"${LOGFILE}"
|
||||||
echo " done."
|
echo " done."
|
||||||
|
|
||||||
{ diff -c "${REFFILE}" "${OUTPUTFILE}" || exit 1; } | cat -v
|
{ diff -c "${REFFILE}" "${OUTPUTFILE}" || exit 1; } | cat -v
|
||||||
|
@ -8,10 +8,8 @@ markdown_parse_mode This is a *MARKDOWN* text mynewlinestartshere with a line br
|
|||||||
|
|
||||||
# test for keyboard, file, venue output
|
# test for keyboard, file, venue output
|
||||||
Text plus keyboard will appear in chat mykeyboardstartshere [ "Yep, sure" , "No, highly unlikely" ]
|
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 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
|
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
|
# test for new inline button
|
||||||
Text plus keyboard will appear in chat mybtextstartshere Button Text myburlstartshere https://www...
|
Text plus keyboard will appear in chat mybtextstartshere Button Text myburlstartshere https://www...
|
||||||
|
@ -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}
|
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
|
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
|
chat:123456 JSON:"latitude": la10, "longitude": lo20
|
||||||
URL:https://api.telegram.org/botbashbottestscript/sendLocation
|
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}
|
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
|
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
|
chat:123456 JSON:"latitude": la10, "longitude": lo20
|
||||||
URL:https://api.telegram.org/botbashbottestscript/sendLocation
|
URL:https://api.telegram.org/botbashbottestscript/sendLocation
|
||||||
|
|
||||||
|
@ -1,17 +1,20 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
|
#### $$VERSION$$ v0.80-dev2-7-g92f022d
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
source "./ALL-tests.inc.sh"
|
source "./ALL-tests.inc.sh"
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
set +f
|
||||||
|
|
||||||
cd "${TESTDIR}" || exit 1
|
cd "${TESTDIR}" || exit 1
|
||||||
|
|
||||||
# source bashbot.sh function, uncomment if you want to test functions
|
# source bashbot.sh function, uncomment if you want to test functions
|
||||||
# shellcheck source=./bashbot.sh
|
# shellcheck source=./bashbot.sh
|
||||||
source "${TESTDIR}/bashbot.sh" source
|
source "${TESTDIR}/bashbot.sh" source
|
||||||
|
# shellcheck source=./bashbot.sh
|
||||||
|
source "${TESTDIR}/commands.sh" source
|
||||||
|
|
||||||
# start writing your tests here ...
|
# start writing your tests here ...
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user