-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfollowback.py
More file actions
29 lines (25 loc) · 811 Bytes
/
followback.py
File metadata and controls
29 lines (25 loc) · 811 Bytes
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
# followback.py
import tweepy
import logging
from config import creates_twitter_object
import time
#saving log to file
logging.basicConfig(level=logging.INFO, filename='followback.log', filemode='w', format='%(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger()
def follow_back(api):
logger.info("Retrieving and following followers")
for follower in tweepy.Cursor(api.followers).items():
if not follower.following:
logger.info(f"Started following {follower.name}")
follower.follow()
def main():
api = creates_twitter_object()
x=0
while True:
follow_back(api)
logger.info("Sleeping...")
x += 1
print(f'followback.py ran {x} time(s), Sleeping...')
time.sleep(60)
if __name__ == "__main__":
main()