From 4408409166b566cbe787e709e48ceaba53e1ce64 Mon Sep 17 00:00:00 2001 From: Massimo Scagliola Date: Sat, 18 May 2024 20:02:40 +0200 Subject: [PATCH] random prompt before tooting --- get-last-rss-post.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/get-last-rss-post.sh b/get-last-rss-post.sh index 425d5a3..ba332ee 100755 --- a/get-last-rss-post.sh +++ b/get-last-rss-post.sh @@ -5,10 +5,11 @@ help() { echo " Downloads the RSS feed of the URL and checks the latest post." echo " It provides a simple way to copy/paste the Title and Link of the post." echo " If toot is installed, it can post the status with custom visibility." + echo " There is also set of funny(?) random variants of the message." echo " Arguments:" echo " -d Checks if the Publication Date of the post is Today." echo " If not, it exits." - echo " -r Uses a random expression. Possibly funny." + echo " -r Uses a random expression." echo " -t Post the link with toot. A prompt will ask confirmation." echo " Accepted value: direct, unlisted, public, private" echo " -h Displays this message." @@ -53,6 +54,13 @@ if [[ "$*" == "" ]]; then exit 1 fi + +echo_msg () { + echo "\n+++++" + echo "$EXPRESSION \"$TITLE\"\n\n$LINK" + echo "+++++\n" +} + today() { # Checks if pubDate is $TODAY echo "Checking if the post pubblication days is ${TODAY}…" @@ -85,15 +93,17 @@ random() { "$ cat new_blog_post.md\n" "🤖 Beep. Boop. I'm a script to share my new blog post:") EXPRESSION=${EXPRESSIONS[ $RANDOM % ${#EXPRESSIONS[@]} ]} + echo_msg } yes_or_no() { while true; do - read -p "$* [y/n]: " yn - case $yn in + read -p "$* [Yes/No/Random]: " ynr + case $ynr in [Yy]*) echo "$EXPRESSION \"$TITLE\"\n\n$LINK" | \ /opt/homebrew/bin/toot post -v $VISIBILITY ; return 0 ;; [Nn]*) echo "Exiting." ; cleanup 0 ;; + [Rr]*) echo "\nPicking up a new expression:"; random ;; esac done } @@ -135,9 +145,8 @@ if [[ "$CHECK_TODAY" == "1" ]]; then today; fi EXPRESSION="Latest article on my blog:" if [[ "$RANDOMIZE" == "1" ]]; then random; fi -echo "\nCopy and Paste this:\n\n+++++" -echo "$EXPRESSION \"$TITLE\"\n\n$LINK" -echo "+++++\n" +echo "\nCopy and Paste this:" +echo_msg if [[ "$TOOT" == "1" ]]; then which toot > /dev/null # Check if toot is installed