-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
33 lines (29 loc) · 1.3 KB
/
main.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
import tweepy, requests, schedule, redditAPI, nasaAPI, astronauts, time
from variables import TWIITER_CONSUMER_KEY, TWIITER_CONSUMER_SECRET, TWIITER_ACCESS_TOKEN, TWIITER_ACCESS_TOKEN_SECRET
#Autenticacion del bot
auth = tweepy.OAuthHandler(TWIITER_CONSUMER_KEY, TWIITER_CONSUMER_SECRET)
auth.set_access_token(TWIITER_ACCESS_TOKEN, TWIITER_ACCESS_TOKEN_SECRET)
api = tweepy.API(auth)
ASAP_TIME= "12:30"
ASTRONAUTS= "13:30"
TOP_TIME_1= "15:00"
TOP_TIME_2= "16:00"
TOP_TIME_3= "17:00"
NEW_TIME_1= "18:00"
NEW_TIME_2= "22:00"
NEW_TIME_3= "00:00"
MINUTOS = 20
#Se declaran las tareas diarias a ejecutar
schedule.every().day.at(ASTRONAUTS).do(astronauts.Post, api)
schedule.every().day.at(ASAP_TIME).do(nasaAPI.Post, api)
schedule.every().day.at(TOP_TIME_1).do(redditAPI.Top_post, api)
schedule.every().day.at(TOP_TIME_2).do(redditAPI.Top_post, api)
schedule.every().day.at(TOP_TIME_3).do(redditAPI.Top_post, api)
schedule.every().day.at(NEW_TIME_1).do(redditAPI.New_post, api)
schedule.every().day.at(NEW_TIME_2).do(redditAPI.New_post, api)
schedule.every().day.at(NEW_TIME_3).do(redditAPI.New_post, api)
print("Empiezan a ejecutarse las tareas...")
while(True):
schedule.run_pending()
print("La ejecución se para por " + str(MINUTOS) + " minutos.")
time.sleep(MINUTOS * 60) #Evita la ejecucion constante del bucle