Created
May 7, 2017 14:58
-
-
Save tsraveling/cea5a12f21c9c09e8f1bff2c7a2000bb to your computer and use it in GitHub Desktop.
Python Twitter Bot
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
| import random | |
| # This file composes the tweets. | |
| def compose(): | |
| return "tweet" |
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
| worker: python3 tweetbot.py |
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
| tweepy==3.5.0 |
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
| python-3.4.3 |
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
| import os | |
| import composer | |
| import time | |
| import random | |
| import tweepy | |
| # Set up Twitter login | |
| CONSUMER_KEY = 'xxx' | |
| CONSUMER_SECRET = 'xxx' | |
| ACCESS_KEY = 'xxx' | |
| ACCESS_SECRET = 'xxx' | |
| auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) | |
| auth.set_access_token(ACCESS_KEY, ACCESS_SECRET) | |
| api = tweepy.API(auth) | |
| # Uncomment these to preview the tweets instead of actually tweeting them | |
| #for x in range(0,20): | |
| # tweet = composer.compose() | |
| # print(tweet + " (%u)" % len(tweet)) | |
| #exit() | |
| while 1: | |
| tweet = composer.compose() | |
| print("Composing tweet: " + tweet) | |
| api.update_status(tweet) | |
| base_time = 75*60 | |
| random_add = (random.randint(0,60))*60 | |
| next_time = base_time + random_add | |
| print("Doing another one in %u minutes" % (next_time / 60)) | |
| time.sleep(next_time) | |
| pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment