-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
44 lines (38 loc) · 1.13 KB
/
bot.py
File metadata and controls
44 lines (38 loc) · 1.13 KB
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
import tweepy
from time import sleep
def authentication():
consumer_key = ""
consumer_secret = ""
access_token = ""
access_token_secret = ""
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
return auth
def interact(keyword, number_of_tweets):
for tweet in tweepy.Cursor(api.search, keyword).items(number_of_tweets):
try:
tweet.retweet()
tweet.favorite()
except tweepy.TweepError as e:
print(e.reason)
except StopIteration:
break
def follow_back(application):
for follower in tweepy.Cursor(application.followers).items():
try:
follower.follow()
except tweepy.TweepError as e:
print(e.reason)
except StopIteration:
break
if __name__ == "__main__":
auth = authentication()
api = tweepy.API(auth)
number_of_tweets =
search_list = []
while(True):
follow_back(api)
for item in search_list:
interact(item, number_of_tweets)
print("pause")
sleep(1700)