-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added files via upload. (retweet.py & keys.py)
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Twitter application consumer keys and access tokens. | ||
# Remember, keep this information private. | ||
consumer_key = 'XXXXXXXXXX' | ||
consumer_secret = 'XXXXXXXXXX' | ||
access_token = 'XXXXXXXXXX' | ||
access_token_secret = 'XXXXXXXXXX' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Retweet bot for Twitter, using Python and Tweepy. | ||
# Search query via hashtag or keyword. | ||
# Author: Tyler L. Jones || CyberVox | ||
# Date: Saturday, May 20th - 2017. | ||
# License: MIT License. | ||
|
||
import tweepy | ||
from time import sleep | ||
# Import in your Twitter application keys, tokens, and secrets. | ||
# Make sure your keys.py file lives in the same directory as this .py file. | ||
from keys import * | ||
|
||
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | ||
auth.set_access_token(access_token, access_token_secret) | ||
api = tweepy.API(auth) | ||
|
||
# Where q='#example', change #example to whatever hashtag or keyword you want to search. | ||
# Where items(5), change 5 to the amount of retweets you want to tweet. | ||
# Make sure you read Twitter's rules on automation - don't spam! | ||
for tweet in tweepy.Cursor(api.search, q='#example').items(5): | ||
try: | ||
print('\nRetweet Bot found tweet by @' + tweet.user.screen_name + '. ' + 'Attempting to retweet.') | ||
|
||
tweet.retweet() | ||
print('Retweet published successfully.') | ||
|
||
# Where sleep(10), sleep is measured in seconds. | ||
# Change 10 to amount of seconds you want to have in-between retweets. | ||
# Read Twitter's rules on automation. Don't spam! | ||
sleep(10) | ||
|
||
# Some basic error handling. Will print out why retweet failed, into your terminal. | ||
except tweepy.TweepError as error: | ||
print('\nError. Retweet not successful. Reason: ') | ||
print(error.reason) | ||
|
||
except StopIteration: | ||
break |