Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added a twitter retweet bot
  • Loading branch information
iyanuashiri committed Oct 18, 2017
commit 4e963ff2ea411852a695dfda3663981ed53dd450
31 changes: 31 additions & 0 deletions bin/twitter_retweet_bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import tweepy # This is a Twitter API helper library.
import time


# You should get the following keys and authentication codes for your Twitter account
# Visit apps.twitter.com
consumer_key = 'consumer_key'
consumer_secret = 'consumer_secret'
access_token = 'access_token'
access_token_secret = 'access_token_secret'


# Twitter requires 0Auth2 authentication. You can readup about this.
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)


def retweet_bot():
for tweet in tweepy.Cursor(api.search, q='Hashtag to listen for').items(10):
try:
print('Twitter user: ' + '@' + tweet.user.screen_name)
tweet.retweet()
print('\nDone')
time.sleep(5) # You can remove the time module, if you want the program to continuously retweet
except tweepy.error.TweepError:
pass


if __name__ == '__main__':
retweet_bot()