Skip to content

Instantly share code, notes, and snippets.

@flimshaw
Created July 24, 2012 15:00
Show Gist options
  • Save flimshaw/3170505 to your computer and use it in GitHub Desktop.
Save flimshaw/3170505 to your computer and use it in GitHub Desktop.
A python script that prints out all tweets mentioning Columbo
import tweetstream
import time
# receipt printer driver
import printer as rp
printer = rp.RPrinter()
print "TwitterFeed!"
stream = tweetstream.FilterStream("##TWITTERNAME##", "##TWITTERPASSWORD##", track=["columbo"])
for tweet in stream:
print "Tweet Received!"
# if it's a valid tweet
if 'user' in tweet:
# print date
tweetDate = time.strptime(tweet['created_at'], "%a %b %d %H:%M:%S +0000 %Y")
printer.println(time.strftime("%b.%d %H:%M:%S", tweetDate))
# print sender
printer.toggleMode(8) # turn bold on
printer.printChar("@%s:\n" % (tweet['user']['screen_name'].encode("ascii", "ignore")))
printer.toggleMode(8) # turn bold off
# print tweet
printer.printChar(tweet['text'].encode("ascii", "ignore"))
printer.printChar("\n\n")
# give the printer a second
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment