Skip to content

Instantly share code, notes, and snippets.

@VADemon
Last active April 17, 2018 12:28
Show Gist options
  • Save VADemon/0d45e8ae94c1834c4f36de02b27257d0 to your computer and use it in GitHub Desktop.
Save VADemon/0d45e8ae94c1834c4f36de02b27257d0 to your computer and use it in GitHub Desktop.
Monitoring of profile comments for Steam. Please use it on your own profile >.>
#!/bin/bash
# Install GitForWindows, it comes with Git Bash - Bash Shell, the Linux Console:
# https://git-scm.com/download/win
# (or you can try to use your Windows 10 unix shell)
#
# Next step: Change the URL and save folder below
# Double click "comment-watcher.sh"
# Press Ctrl+C to close this script
# or Start from Terminal: Launch "Git Bash" in the folder where you saved this script
# and write "sh comment-watcher.sh", press Enter to start this script
# ~ is home folder. C:/Users/<USER>/ on Windows
# ~ DOESNT WORK ON WINDOWS! MINGW64 doesn't evaluate it correctly when used not on console!
# $(pwd) is the current folder (if you Double-Click: where the script is saved)
savefolder="$(pwd)"
tmpfile="/tmp/steam_allcomments"
# sleep time between downloads. 5 seconds is stalkerlevel 80
sleeptime=5
URL="https://steamcommunity.com/id/VADemon/allcomments"
while true; do
curl --silent $URL > $tmpfile
newdate=$(egrep -o -m 1 'data\-timestamp\=.([[:digit:]]+).' $tmpfile | egrep -o "[[:digit:]]+")
if [[ ! -z $olddate && $olddate != $newdate ]]; then
echo "New comment found from: "$(date --date="@$newdate" +%Y%M%d_%H-%M-%S);
olddate=$newdate
mv $tmpfile $(echo $savefolder)"/steamcomment_"$(date --date="@$newdate" +%Y%M%d_%H-%M-%S)".html";
elif [[ -z $newdate ]]; then
echo -e "Couldn't extract NEWDATE! Maybe the download failed!"
elif [[ $olddate == $newdate ]]; then
# do nothing to avoid console spam
:
else
# set olddate, but dont download the page. May miss the first comment of the day
if [[ -z $olddate ]]; then
echo "Skipping first comment: "$(date --date="@$newdate" +%Y%M%d_%H-%M-%S);
fi
olddate=$newdate
echo "Olddate updated to: "$(date --date="@$olddate" +%Y%M%d_%H-%M-%S)
fi
sleep $sleeptime
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment