Created
October 29, 2012 18:40
-
-
Save YoSmudge/3975608 to your computer and use it in GitHub Desktop.
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
from escpos import * | |
import requests | |
import sys | |
import textwrap | |
from time import sleep | |
import twitter | |
p = escpos.Escpos(7344, 3, 0) | |
devwidth = 31 | |
pad = " " | |
def printLine(): | |
""" | |
Print a line across the screen | |
""" | |
for i in range(0,devwidth): | |
sendString('#') | |
def sendString(s): | |
p.text(s) | |
sys.stdout.write(s) | |
def newLine(): | |
sendString("\n"+pad) | |
def printString(txt): | |
wrapped = textwrap.wrap(txt,devwidth) | |
for line in wrapped: | |
newLine() | |
sendString(line) | |
newLine() | |
try: | |
t = twitter.Api( | |
consumer_key='', | |
consumer_secret='', | |
access_token_key='', | |
access_token_secret='' | |
) | |
latestId = 0 | |
newLine() | |
newLine() | |
while True: | |
#Request the twitter API stuff | |
s = t.GetMentions(since_id=latestId) | |
s.reverse() | |
for status in s: | |
if status.id > latestId: | |
latestId = status.id | |
printLine() | |
printString("Tweet from @{0}".format(status.user.screen_name)) | |
printString("{0}".format(status.text.encode('ascii', 'ignore'))) | |
printLine() | |
newLine() | |
newLine() | |
newLine() | |
newLine() | |
sleep(2) | |
sleep(30) | |
except KeyboardInterrupt: | |
print "Shutting down" | |
p.__del__() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment