###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)

while True:
    public_tweets = api.mentions_timeline(count=2) #my mentions in my time line return two of them
    for tweet in public_tweets:    
        
        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)
    
    
    
