Compare commits

..

1 Commits

Author SHA1 Message Date
9d74765484 templating, rate-limiting, etc. 2026-04-02 22:44:23 +03:00
2 changed files with 3 additions and 28 deletions

View File

@@ -1,6 +1,2 @@
TELEGRAM_BOT_TOKEN=
TELEGRAM_CHAT_ID=
RATE_LIMITER_MS=1000 # default is 1s
# Templates live in ~/.config/whisper/templates/
# Use: whisper -t TEMPLATE_NAME -p "param1" "param2"

View File

@@ -4,34 +4,13 @@
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
echo '--- test 1: plain text ---\n'
"$SCRIPT_DIR/whisper" --via telegram -m "Hello from whisper test" || true
"$SCRIPT_DIR/whisper" -t telegram -m "Hello from whisper test" || true
echo '\n--- test 2: HTML formatting ---\n'
"$SCRIPT_DIR/whisper" --via telegram -m "<b>bold</b> <i>italic</i> <code>code</code>" || true
"$SCRIPT_DIR/whisper" -t telegram -m "<b>bold</b> <i>italic</i> <code>code</code>" || true
echo '\n--- test 3: multiline ---\n'
MSG=$(printf 'Line one\nLine two\nLine three')
"$SCRIPT_DIR/whisper" --via telegram -m "$MSG" || true
printf '\n--- test 4: template substitution ---\n'
mkdir -p "$HOME/.config/whisper/templates"
printf 'Deploy: {1} version {2}' > "$HOME/.config/whisper/templates/_test-deploy"
"$SCRIPT_DIR/whisper" -t _test-deploy -p "myapp" "v1.0.0" || true
printf '\n--- test 5: template with file injection ---\n'
printf 'log output here' > /tmp/_whisper-test-file.txt
"$SCRIPT_DIR/whisper" -t _test-deploy -p "myapp" @/tmp/_whisper-test-file.txt || true
printf '\n--- test 6: mutual exclusion (expect error) ---\n'
"$SCRIPT_DIR/whisper" -m "hello" -t _test-deploy -p "a" "b" 2>&1 || true
printf '\n--- test 7: missing template (expect error) ---\n'
"$SCRIPT_DIR/whisper" -t _nonexistent -p "x" 2>&1 || true
printf '\n--- test 8: transport override via --via ---\n'
"$SCRIPT_DIR/whisper" --via telegram -t _test-deploy -p "myapp" "v2.0.0" || true
printf '\n--- cleanup ---\n'
rm -f "$HOME/.config/whisper/templates/_test-deploy" /tmp/_whisper-test-file.txt
"$SCRIPT_DIR/whisper" -t telegram -m "$MSG" || true
echo '\nAll tests done.\n'