Skip to content

Instantly share code, notes, and snippets.

@stelcheck
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stelcheck/576ac8b4d9012f7d72c2 to your computer and use it in GitHub Desktop.
Save stelcheck/576ac8b4d9012f7d72c2 to your computer and use it in GitHub Desktop.
Tweet updates in your terminal
TWEET_FEED="/tmp/tweets"
TWEET_FEED_PIDFILE="/tmp/tweets.pid"
checkTweetsFetcher () {
TWEET_FEED_PID="$(cat ${TWEET_FEED_PIDFILE} 2> /dev/null)"
if
! kill -0 "${TWEET_FEED_PID}" 2> /dev/null
then
echo -n "Starting tweet feed check... " | green | bold
rm -rf ${TWEET_FEED}
touch ${TWEET_FEED}
node ~/Sources/tweets.js \
nodejs \
ansible \
&> ${TWEET_FEED} &
echo "${!}" > ${TWEET_FEED_PIDFILE}
echo 'Started!' | green | bold
fi
}
checkTweets () {
checkTweetsFetcher
cat ${TWEET_FEED}
echo -n "" > ${TWEET_FEED}
}
checkTweetsFetcher
require('colors');
var Twitter = require('node-tweet-stream')
var t = new Twitter({
consumer_key: 'asdf',
consumer_secret: 'asf',
token: 'asfd',
token_secret: 'adf'
});
t.on('tweet', function (tweet) {
if (tweet.text.indexOf('RT ') === 0) {
return;
}
var url = 'https://www.twitter.com/' + tweet.user.screen_name + '/status/' + tweet.id;
console.log(
tweet.created_at.yellow.bold,
('@' + tweet.user.screen_name).magenta, tweet.text.cyan)
console.log(
url.grey
)
console.log('')
})
t.on('error', function (err) {
console.log('Tweet feed had an error!')
})
for (var i = 2; i < process.argv.length; i++) {
var tag = process.argv[i]
t.track(tag)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment