Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
BotADayBotAway/2017/12/04/realDrilledTrump.sh
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
54 lines (46 sloc)
2.01 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Mix Trump and Drils tweets together | |
# https://twitter.com/MadScientist212/status/630879791881662464 | |
SCRIPTDIR=$(dirname $0) | |
USERS=( "dril" "realDonaldTrump" ) | |
SOURCE="$SCRIPTDIR/Sources/$(date +%Y-%m-%d)" | |
TWEETS=$(mktemp) | |
pushd $SCRIPTDIR >/dev/null | |
# The source document will be produced once a day | |
if [ ! -e $SOURCE ]; then | |
# For each USER in the list take their last n tweets and add the IDs to a | |
# file for later processing | |
for USER in ${USERS[@]}; do | |
>&2 echo $USER | |
t timeline -n 100 -c $USER | grep "^[0-9]" | cut -d, -f1 >> $TWEETS | |
done | |
# Print out the ammount of IDs (hopefully n*#USERS) | |
>&2 wc $TWEETS | |
>&2 echo "[*] Getting text" | |
# For every ID check if its a retweet and remove it, the rest add the full | |
# text to a source document. Shuffle to IDs to add some "randomness" | |
while read ID; do | |
../../../Tools/tweet.sh/tweet.sh get $ID | jq .full_text |\ | |
sed -e "/^\"RT/d" | sed -e "s/\\\u/ \\\u/g" >> $SOURCE | |
done < <( shuf $TWEETS ) | |
sed -i "s/http[s]*:\/\/[a-zA-Z.\/0-9]*//g;s/^\"//g;s/\"$//g" $SOURCE | |
else | |
rm -f "$SCRIPTDIR/Sources/$(date --date="- 1 day" +%Y-%m-%d)" | |
fi | |
WORDS=$(seq 10 23 | shuf | head -1) | |
FULLTEXT=$(../../../Tools/markov-bash/markov.sh $SOURCE $WORDS | sed -e "s/\\\\n/\n/g" | sed -e "s/\\\\/\"/g;s/ \" //g" ) | |
while egrep -i -q -f Connectives <(echo $FULLTEXT); do | |
# >&2 echo "bad form: $FULLTEXT" | |
FULLTEXT=$(../../../Tools/markov-bash/markov.sh $SOURCE $WORDS | sed -e "s/\\\\n/\n/g" | sed -e "s/\\\\/\"/g;s/ \" //g" ) | |
done | |
NOOFQUOTES=$(cat <<< "${FULLTEXT}" | egrep -o '"' | wc -l) | |
eCheck=$(( $NOOFQUOTES & 1 )) | |
TWEETABLE="" | |
if [ "$eCheck" -eq "1" ]; then | |
TWEETABLE=$(cat <<< "${FULLTEXT}" | sed "s/\([^ ]*\)\"/\"\1\"/g;s/\"\([^ ]*\)/\"\1\"/g" | sed "s/\" /» /g;s/ \"/ «/g" | sed "s/\"//g") | |
else | |
TWEETABLE=$(cat <<< "${FULLTEXT}" | sed "s/\" /» /g;s/ \"/ «/g;s/\"$/»/g;s/^\"/«/g" | sed "s/\"//g") | |
fi | |
echo $TWEETABLE | |
../../../Tools/tweet.sh/tweet.sh post "${TWEETABLE}" | |
popd >/dev/null |