Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##Import Libraries
- import twitter
- import serial
- import time
- ##authenticate yourself with twitter
- api = twitter.Api(consumer_key='XXXXXXXXXXXX',
- consumer_secret='XXXXXXXXXXX', access_token_key='XXXXXXXXXXXX',
- access_token_secret='XXXXXXXXXXXXXXXXXXXXXX')
- ##set to your serial port
- ser = serial.Serial('/dev/tty.usbmodem411', 19200)
- ## check serial port
- def checkokay():
- ser.flushInput()
- time.sleep(3)
- line= ser.readline()
- time.sleep(3)
- if line == ' ':
- line=ser.readline()
- print 'here'
- ## Welcome message
- print 'Welcome To autokahwa!'
- print 'Making kahwa..'
- def autokahwa():
- status = [ ]
- x = 0
- status = api.GetUserTimeline('X') ##grab latest statuses
- checkIt = [s.text for s in status] ##put status in an array
- drip = checkIt[0].split() ##split first tweet into words
- ## check for match and write to serial if match
- if drip[0] == '#autokahwa':
- print 'Tweet Recieved, Making Kahwa'
- ser.write('1')
- elif drip[0] == '#autokahwastop': ##break if done
- ser.write('0')
- print 'stopped, awaiting instructions.'
- else:
- ser.write('0')
- print 'Awaiting Tweet'
- while 1:
- autokahwa() ## call autokahwa function
- time.sleep(15) ## sleep for 15 seconds to avoid rate limiting
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement