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() {
|
|
|
|
sed -e 's/.*<img>\(.*\)<\/img>.*/\1/g' <<< $1
|
|
|
|
}
|
|
|
|
|
|
|
|
extract_text() {
|
|
|
|
sed -e "s/\(.*\)<img>.*<\/img>\(.*\)/\1\2/g" <<< $1
|
|
|
|
}
|
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-19 16:45:15 +01:00
|
|
|
text=`extract_text "$line"`
|
|
|
|
image=`extract_image "$line"`
|
|
|
|
echo "[$(date)][INFO] Now tooting: $text"
|
|
|
|
echo "[$(date)][INFO] with image: $image"
|
|
|
|
./toot.sh -i=images/$image $text >/dev/null 2>&1 &
|
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
|