Created
May 9, 2014 23:53
-
-
Save Aaron1011/567bc00f02b87b7e3529 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
###TeCoEd and a T-REX:-) | |
import sys, subprocess, urllib, time, tweepy | |
import piface.pfio as pfio | |
pfio.init() | |
# == OAuth Authentication == | |
# | |
# This mode of authentication is the new preferred way | |
# of authenticating with Twitter. | |
# The consumer keys can be found on your application's Details | |
# page located at https://dev.twitter.com/apps (under "OAuth settings") | |
consumer_key= 'XXXXXXXXXXXXXXXXXXXXXXXXX' | |
consumer_secret= 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | |
# The access tokens can be found on your applications's Details | |
# page located at https://dev.twitter.com/apps (located | |
# under "Your access token") | |
access_token= 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | |
access_token_secret= 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
auth.set_access_token(access_token, access_token_secret) | |
api = tweepy.API(auth) | |
print api.me() | |
class DinoStreamListener(tweepy.StreamListener): | |
def on_status(self, tweet): | |
if tweet.text == "@dan_aldred ROAR": #Phrase when the dino respsonds to pfio.digital_write(7, 1) | |
print tweet.text | |
pfio.digital_write(7, 1) | |
time.sleep(10) | |
print tweet.user.screen_name | |
else: | |
print tweet.text | |
pfio.digital_write(7, 0) | |
print tweet.user.screen_name | |
time.sleep(60) | |
stream = tweepy.Stream(auth, DinoStreamListener()) | |
try: | |
stream.userstream() | |
except KeyboardInterrupt: | |
print "Exiting!" | |
stream.disconnect() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment