forked from 0xGrimnir/Simple-Retweet-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathretweet.py
45 lines (32 loc) · 1.09 KB
/
retweet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'''
retweet.py: retweet bot to retweet #VetsWhoCode
26 December 2019
Vicki Langer (@vicki_langer)
'''
import tweepy
from time import sleep
from os import environ
consumer_key = environ['consumer_key']
consumer_secret = environ['consumer_secret']
access_token = environ['access_token']
access_token_secret = environ['access_token_secret']
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
user = api.me()
print(user.name)
def main():
search_term = ("#VetsWhoCode", "#vetsWhoCode")
number_of_tweets = 5
for tweet in tweepy.Cursor(api.search, search_term).items(number_of_tweets):
try:
print('\nFound tweet by @' + tweet.user.screen_name)
tweet.retweet()
print("Yay! Tweet was retweeted :)")
# sleep is measured in seconds
sleep(10)
except tweepy.TweepError as error:
print('wtf, why isn\'t it working?' + error.reason)
except StopIteration:
break
main()