Quantcast
Channel: Pimoroni Buccaneers - Latest posts
Viewing all articles
Browse latest Browse all 53866

Twitter #hashtag to scroll pHAT

$
0
0
import time
import tweepy
import scrollphat

scrollphat.set_brightness(2)

class MyStreamListener(tweepy.StreamListener):
    def on_status(self, status):
        if not status.text.startswith('RT'):
            scroll_tweet(status)
    def on_error(self, status_code):
        if status_code == 420:
            return False

def scroll_tweet(status):
    status = '> > > > > >  @%s: %s    ' % (status.user.screen_name.upper(), status.text.upper())
    status = status.encode('ascii', 'ignore').decode('ascii') + '          '
    #status_string_length = len(status)
    scrollphat.write_string(status)
    status_length = scrollphat.buffer_len()
    print status
    print
    print status_length
    print
    while status_length >= 0:
        scrollphat.scroll()
        time.sleep(0.1)
        status_length -= 1
        #print status_length

consumer_key =''
consumer_secret =''

access_token = ''
access_token_secret = ''

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)

myStreamListener = MyStreamListener()
myStream = tweepy.Stream(auth = api.auth, listener=myStreamListener)

myStream.filter(track=['#saintsfc', '@BBCSport'], async=False)

Viewing all articles
Browse latest Browse all 53866

Trending Articles