2019-02-19 16:45:15 +01:00
|
|
|
#
|
|
|
|
# CONFIGURATION
|
|
|
|
#
|
2019-02-19 13:53:09 +01:00
|
|
|
|
2019-02-19 16:45:15 +01:00
|
|
|
# Interval between two consecutive posts
|
2019-02-19 13:53:09 +01:00
|
|
|
SLEEP_INTERVAL=3h
|
|
|
|
|
2019-02-19 16:45:15 +01:00
|
|
|
# File containing the toots to post
|
|
|
|
DATA_FILE=megafono.txt
|
|
|
|
|
|
|
|
#
|
|
|
|
# CONFIGURATION END
|
|
|
|
#
|
|
|
|
|
|
|
|
extract_image() {
|
2019-02-19 16:56:54 +01:00
|
|
|
|
|
|
|
sed -n -e 's/.*<img>\(.*\)<\/img>.*/\1/p' <<< $1
|
2019-02-19 16:45:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
extract_text() {
|
2019-02-19 17:44:29 +01:00
|
|
|
sed -e "s/<img>.*<\/img>/ /g" <<< $1
|
2019-02-19 16:45:15 +01:00
|
|
|
}
|
2019-02-19 13:57:34 +01:00
|
|
|
|
|
|
|
while :
|
2019-02-19 13:53:09 +01:00
|
|
|
do
|
2019-02-19 13:57:34 +01:00
|
|
|
# Last line should be empty, so we dont need an additional read here
|
|
|
|
# after the while loop
|
|
|
|
while read line
|
|
|
|
do
|
2019-02-20 02:25:43 +01:00
|
|
|
text="#avviso%0A"`extract_text "$line"`
|
2019-02-19 16:45:15 +01:00
|
|
|
image=`extract_image "$line"`
|
|
|
|
echo "[$(date)][INFO] Now tooting: $text"
|
2019-02-19 16:56:54 +01:00
|
|
|
if [ "$image" != "" ]
|
|
|
|
then
|
|
|
|
echo "[$(date)][INFO] with image: $image"
|
|
|
|
./toot.sh -i=images/$image $text >/dev/null 2>&1 &
|
|
|
|
else
|
|
|
|
./toot.sh $text >/dev/null 2>&1 &
|
|
|
|
fi
|
2019-02-19 13:57:34 +01:00
|
|
|
sleep ${SLEEP_INTERVAL}
|
2019-02-19 16:45:15 +01:00
|
|
|
done < ${DATA_FILE}
|
2019-02-19 13:57:34 +01:00
|
|
|
|
|
|
|
done
|