-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnestlebot_2020.py
40 lines (26 loc) · 944 Bytes
/
nestlebot_2020.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
from nestlebot_functions import *
import time
def main():
print("getting Twitter API")
api = get_twitter_api()
# set tweeting time interval
INTERVAL = 60 * 15 * 1 # tweet every 15 minutes
#INTERVAL = 30 # every 30 seconds, for testing
while True:
print("Time to tweet - LFG")
#get the freshest list of brands
brand_list = get_brands()
try:
#get the image we're gonna tweet
tweet_image_path, item = get_image(brand_list)
#create and post the tweet
generate_tweet(tweet_image_path, item, api)
print("Tweeted!!! Back to sleep...")
except:
print("Tweet failed, RIP. Back to sleep...")
raise
pass
#back to sleep zzzzzz
time.sleep(INTERVAL)
if __name__ == "__main__":
main()