mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-06-13 15:42:20 +00:00
add test and doc for stats, make test send_message more stable
This commit is contained in:
parent
2a66ee928f
commit
8e7583d3b7
|
@ -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.96-dev-7-g0153928
|
#### $$VERSION$$ v0.96-dev3-1-g2a66ee9
|
||||||
|
|
||||||
# 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
|
||||||
|
|
|
@ -74,14 +74,21 @@ Start or Stop your Bot use the following commands:
|
||||||
./bashbot.sh kill
|
./bashbot.sh kill
|
||||||
```
|
```
|
||||||
|
|
||||||
### User count
|
### User stats
|
||||||
|
|
||||||
deprecated, will be removed!
|
To count the total number of users and messages run the following command:
|
||||||
|
|
||||||
|
```
|
||||||
|
./bashbot.sh stats
|
||||||
```
|
```
|
||||||
|
|
||||||
### Sending broadcasts to all users
|
### Sending broadcasts to all users
|
||||||
|
|
||||||
|
To send a broadcast to all of users that ever used the bot run the following command:
|
||||||
|
|
||||||
|
```
|
||||||
|
./bashbot.sh broadcast "Hey! I just wanted to let you know that the bot's been updated!"
|
||||||
```
|
```
|
||||||
deprecated, will be removed!
|
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
@ -246,5 +253,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.96-dev3-0-gdddd1ce
|
#### $$VERSION$$ v0.96-dev3-1-g2a66ee9
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ v0.96-dev3-0-gdddd1ce
|
#### $$VERSION$$ v0.96-dev3-1-g2a66ee9
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
|
@ -32,7 +32,7 @@ trap exit 1 EXIT
|
||||||
cd "${TESTDIR}" || exit
|
cd "${TESTDIR}" || exit
|
||||||
|
|
||||||
echo "Test if $JSONSHFILE exists ..."
|
echo "Test if $JSONSHFILE exists ..."
|
||||||
[ ! -x "$JSONSHFILE" ] && { echo "${NOSUCCESS} Fail diff ${file}!"; exit 1; }
|
[ ! -x "$JSONSHFILE" ] && { echo "${NOSUCCESS} json.sh not found"; exit 1; }
|
||||||
|
|
||||||
echo "Test Sourcing of bashbot.sh ..."
|
echo "Test Sourcing of bashbot.sh ..."
|
||||||
# shellcheck source=./bashbot.sh
|
# shellcheck source=./bashbot.sh
|
||||||
|
@ -44,6 +44,7 @@ trap '' EXIT
|
||||||
cd "${DIRME}" || exit 1
|
cd "${DIRME}" || exit 1
|
||||||
echo "${SUCCESS}"
|
echo "${SUCCESS}"
|
||||||
|
|
||||||
echo "Test bashbot.sh count"
|
echo "Test bashbot.sh stat"
|
||||||
cp "${REFDIR}/count.test" "${TESTDIR}/count.jssh"
|
cp "${REFDIR}/count.test" "${TESTDIR}/count.jssh"
|
||||||
"${TESTDIR}/bashbot.sh" count
|
"${TESTDIR}/bashbot.sh" stats >"${TESTDIR}/stats.out"
|
||||||
|
diff -q "${TESTDIR}/stats.out" "${REFDIR}/stats.out" >>"${LOGFILE}" || { echo "${NOSUCCESS} Fail diff stats output!"; FAIL="1"; }
|
||||||
|
|
1
test/c-init-test/stats.out
Normal file
1
test/c-init-test/stats.out
Normal file
|
@ -0,0 +1 @@
|
||||||
|
A total of 272 messages from 24 users are processed.
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ v0.96-dev-7-g0153928
|
#### $$VERSION$$ v0.96-dev3-1-g2a66ee9
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
|
@ -54,7 +54,12 @@ done < "${INPUTFILE}" 2>>"${LOGFILE}"
|
||||||
|
|
||||||
echo " done."
|
echo " done."
|
||||||
|
|
||||||
{ diff -c "${REFFILE}" "${OUTPUTFILE}" || exit 1; } | cat -v
|
sort -d -o "${OUTPUTFILE}.sort" "${OUTPUTFILE}"
|
||||||
|
sort -d -o "${REFFILE}.sort" "${REFFILE}"
|
||||||
|
|
||||||
|
{ diff -c "${REFFILE}.sort" "${OUTPUTFILE}.sort" || exit 1; } | cat -v
|
||||||
|
rm -f "${REFFILE}.sort"
|
||||||
|
|
||||||
echo " ... all \"send_message\" functions seems to work as expected."
|
echo " ... all \"send_message\" functions seems to work as expected."
|
||||||
echo "${SUCCESS}"
|
echo "${SUCCESS}"
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
bashbottestscript
|
123456789:BASHBOTTESTSCRIPTbashbottestscript_
|
||||||
|
|
Loading…
Reference in New Issue
Block a user