def main(params, tracklist): # twitter info consumer_key = params.get('twitter', 'consumer_key') consumer_secret = params.get('twitter', 'consumer_secret') access_token = params.get('twitter', 'access_token') access_token_secret = params.get('twitter', 'access_secret') # auth & api auth = tweepy.auth.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api = tweepy.API(auth) # markov corpus = params.get('markov', 'corpus') is_pickled = params.getboolean('markov', 'pickled') m = Markov(corpus) if is_pickled: m.load_db() else: m.make_db() # listener print 'Starting listener for "{}"...'.format(', '.join(tracklist)) listener = Listener(m, is_pickled, api=api) stream = tweepy.Stream(auth, listener) stream.filter(track=tracklist)
def main(params): consumer_key = params.get('twitter', 'consumer_key') consumer_secret = params.get('twitter', 'consumer_secret') access_token = params.get('twitter', 'access_token') access_token_secret = params.get('twitter', 'access_secret') auth = tweepy.auth.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api = tweepy.API(auth) corpus = params.get('markov', 'corpus') is_pickled = params.getboolean('markov', 'pickled') m = Markov(corpus) if is_pickled: m.load_db() else: m.make_db() text = m.gen(climit=140) api.update_status(text)