From 63341802b81f97c09245ef9bc871ccf5f37a4e29 Mon Sep 17 00:00:00 2001 From: Cinabre Date: Sat, 9 May 2020 23:11:11 +0200 Subject: [PATCH] Update 'run.py' --- advice.py => run.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) rename advice.py => run.py (60%) diff --git a/advice.py b/run.py similarity index 60% rename from advice.py rename to run.py index 8fdad47..7c9f87d 100644 --- a/advice.py +++ b/run.py @@ -1,5 +1,6 @@ import requests from config import advice_api +from twitter import tweet import time def fetch_advice(): @@ -17,18 +18,20 @@ def create_file(message): write_file.write(message) def main(): - t = time.localtime() - current_time = int(time.strftime("%H", t)) - print("it's : ",current_time) - while current_time != 23 : + while True : + t = time.localtime() current_time = int(time.strftime("%H", t)) + print("it's : ",current_time) + while current_time != 23 : + current_time = int(time.strftime("%H", t)) + time.sleep(600) + advice = fetch_advice() + print(advice) + tweet(advice) + create_file(advice) + t = time.localtime() + current_time = time.strftime("%H", t) time.sleep(3600) - advice = fetch_advice() - print(advice) - create_file(advice) - t = time.localtime() - current_time = time.strftime("%H", t) - time.sleep(3600) if __name__ == '__main__': try :