Last active
August 29, 2015 14:14
-
-
Save amanda/bc8f130c4af89cdf979d to your computer and use it in GitHub Desktop.
Skeleton code for Twitter bot built using Python/Twython
This file contains 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
#!/usr/bin/env python | |
from twython import Twython, TwythonError | |
import os | |
import time | |
'''twitter creds and setup''' | |
CONSUMER_KEY = os.getenv('CONSUMER_KEY') | |
CONSUMER_SECRET = os.getenv('CONSUMER_SECRET') | |
OAUTH_TOKEN = os.getenv('OAUTH_TOKEN') | |
OAUTH_SECRET = os.getenv('OAUTH_SECRET') | |
'''twitter client setup''' | |
twitter = Twython(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_SECRET) | |
def make_tweet(): | |
'''logic for generating tweet text | |
goes here, returns tweet str to post''' | |
pass | |
def run(): | |
'''post to twitter and runs the bot | |
to tweet at a specified interval''' | |
status = make_tweet() | |
twitter.update_status(status=status) | |
time.sleep(3600) # once per hour, change this if you want | |
if __name__ == '__main__': | |
while True: | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment