Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MelaniaBot
oauthlib==1.1.2
requests==2.10.0
requests-oauthlib==0.6.2
six==1.10.0
tweepy==3.5.0
import os
import tweepy
auth = tweepy.OAuthHandler(
os.environ.get('TWITTER_CONSUMER_KEY'),
os.environ.get('TWITTER_CONSUMER_SECRET')
)
auth.set_access_token(
os.environ.get('TWITTER_ACCESS_TOKEN'),
os.environ.get('TWITTER_ACCESS_TOKEN_SECRET')
)
api = tweepy.API(auth)
class FLOTUSStreamListener(tweepy.StreamListener):
def on_status(self, status):
tweet_from_melania_bot(status.text)
return True
def on_connect(self):
print "Connected..."
return True
def on_timeout(self):
print 'Stream timeing out...'
return True
def tweet_from_melania_bot(status):
try:
status = api.update_status(status)
except:
pass
return status
def main():
flotusStreamListener = FLOTUSStreamListener()
myStream = tweepy.Stream(auth=api.auth, listener=flotusStreamListener)
myStream.filter(follow=['flotus'])
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment