Created
April 22, 2018 12:55
-
-
Save tigranbs/2024f80c9a7b9c1e52cef5ee657b3470 to your computer and use it in GitHub Desktop.
Simple Twitter Bot for Retweeting #RejectSerj Armenian protest tweets
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/python3.5 | |
import tweepy | |
from time import sleep | |
consumer_key = "<KEY HERE>" | |
consumer_secret = "<KEY HERE>" | |
access_token = "<KEY HERE>" | |
access_token_secret = "<KEY HERE>" | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
auth.set_access_token(access_token, access_token_secret) | |
api = tweepy.API(auth) | |
for tweet in tweepy.Cursor(api.search, q='#RejectSerzh+OR+#ՄերժիրՍերժին+OR+Pashinyan').items(15): | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment