Last active
March 31, 2016 01:21
-
-
Save MarkEEaton/bbdefd4df835726ae05f to your computer and use it in GitHub Desktop.
Bot Day: Script 2
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 | |
# -*- coding: utf-8 -*- | |
# Original script (kept up to date): https://github.com/robincamille/bot-tutorial/blob/master/mybot2.py | |
# Twitter Bot Starter Kit: Bot 2 | |
# This bot tweets a text file line by line, waiting a | |
# given period of time between tweets. | |
# Download a Project Gutenberg "Plain Text UTF-8" file, | |
# open it in Notepad, remove junk at beginning, | |
# and replace all double-linebreaks with single linebreaks. | |
# Housekeeping: do not edit | |
import tweepy, time | |
from credentials import * | |
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) | |
auth.set_access_token(ACCESS_TOKEN, ACCESS_SECRET) | |
api = tweepy.API(auth) | |
# What the bot will tweet | |
filename = open('twain.txt','r') | |
tweettext = filename.readlines() | |
filename.close() | |
for line in tweettext[0:5]: #Will only write first 5 lines | |
api.update_status(line) | |
print line | |
time.sleep(15) # Sleep for 15 seconds | |
print "All done!" | |
# To quit early: CTRL+C and wait a few seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment