Added toot
This commit is contained in:
parent
82136e3719
commit
920e0056b4
13
README.md
13
README.md
|
@ -6,8 +6,17 @@ Simple script to get the latest post link from a RSS feed (usually, the second o
|
|||
|
||||
It provides a quick way to copy/paste the title and URL for social media.
|
||||
|
||||
I wanted to integrate it with tools [toot](https://toot.bezdomni.net/), but with 2FA it's impossible to use it.
|
||||
If [toot](https://toot.bezdomni.net/) is installed, it can post the output as a status. A prompt will ask it.
|
||||
|
||||
This is mainly for personal use. *CTRL-C/CTRL-V FTW!*
|
||||
|
||||
If I had to choose a license, it would be MIT.
|
||||
If I had to choose a license, it would be MIT.
|
||||
|
||||
## TO DO
|
||||
|
||||
- Multiple arguments with getopts
|
||||
- Check publish date
|
||||
- Post with Toot
|
||||
- Toot Visibility?
|
||||
- ...?
|
||||
- Custom template for post
|
|
@ -11,6 +11,7 @@
|
|||
help() {
|
||||
sed -rn 's/^### ?//;T;p' "$0"
|
||||
}
|
||||
|
||||
if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]] || [[ "$1" == "" ]]; then
|
||||
help
|
||||
exit 1
|
||||
|
@ -23,7 +24,7 @@ if [[ "$1" == "-t" ]] || [[ "$1" == "--today" ]]; then
|
|||
CHECK_TODAY=1
|
||||
fi
|
||||
|
||||
today () {
|
||||
today() {
|
||||
# Checks if pubDate is $TODAY
|
||||
echo $PUB_DATE | grep -q "$TODAY"
|
||||
if [[ "$?" == "0" ]]; then # pubDate is $TODAY
|
||||
|
@ -34,8 +35,19 @@ today () {
|
|||
fi
|
||||
}
|
||||
|
||||
yes_or_no() {
|
||||
while true; do
|
||||
read -p "$* [y/n]: " yn
|
||||
case $yn in
|
||||
[Yy]*) echo "Latest article from my blog: \"$TITLE\"\n\n$LINK" | /opt/homebrew/bin/toot post; return 0 ;;
|
||||
[Nn]*) echo "Exiting." ; exit 0 ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
cleanup () {
|
||||
rm -f feed.xml
|
||||
rm -f status.txt
|
||||
exit $1
|
||||
}
|
||||
|
||||
|
@ -62,10 +74,10 @@ PUB_DATE=$(sed -n "/<link>$LINK_FIXED/,/pubDate/p" feed.xml | tail -n 1 | sed 's
|
|||
|
||||
if [[ "$CHECK_TODAY" == "1" ]]; then today; fi
|
||||
|
||||
echo "\nCopy and Paste this:\n\n\
|
||||
+++++\n\
|
||||
Latest article from my blog: \"$TITLE\"\n\
|
||||
$LINK
|
||||
+++++"
|
||||
echo "\nCopy and Paste this:\n\n+++++"
|
||||
echo "Latest article from my blog: \"$TITLE\"\n\n$LINK"
|
||||
echo "+++++"
|
||||
|
||||
yes_or_no "Post the it as status?" && echo "Ok."
|
||||
|
||||
cleanup 0
|
Loading…
Reference in New Issue