Created
September 1, 2012 00:20
-
-
Save avoidedlife/3561691 to your computer and use it in GitHub Desktop.
Bash script using xmlstarlet to return latest twitter status to minecraft server chat via screen
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 | |
# minecraft screen session | |
SCREEN_SESSION=minecraft | |
# using xmlstarlet http://xmlstar.sourceforge.net to parse xml/rss and return latest twitter status | |
function TwitGet () { | |
RSS_URL=api.twitter.com/1/statuses/user_timeline/$1.rss | |
rssversion=$(wget ${RSS_URL} -O - 2>/dev/null | | |
xmlstarlet sel -T -t -v '/rss/channel/item[1]/title') | |
echo "$rssversion" | |
} | |
# Twitter feeds - usage "VAR=$(TwitGet twittername)" | |
NOTCH=$(TwitGet notch) | |
JEB=$(TwitGet jeb_) | |
DINNER=$(TwitGet Dinnerbone) | |
# one line per twitter entry - usage screen -p 0 -S ${SCREEN_SESSION} -X stuff "`printf "say ${VAR}\r"`" | |
if [ : ]; then | |
screen -p 0 -S ${SCREEN_SESSION} -X stuff "`printf "say ${NOTCH}\r"`" | |
screen -p 0 -S ${SCREEN_SESSION} -X stuff "`printf "say ${JEB}\r"`" | |
screen -p 0 -S ${SCREEN_SESSION} -X stuff "`printf "say ${DINNER}\r"`" | |
exit 0 | |
fi | |
#hacked together by avoidedlife - | |
#by searching and asking the intenets and putting bits and pieces of code together |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment