mirror of
https://github.com/michivonah/themepark-alerts.git
synced 2025-12-22 20:36:27 +01:00
add refresh time to reduce api requests
This commit is contained in:
parent
35278de6cc
commit
c8ca8e1362
1 changed files with 5 additions and 1 deletions
6
main.py
6
main.py
|
|
@ -13,6 +13,7 @@ load_dotenv()
|
||||||
# Global defintions
|
# Global defintions
|
||||||
subscribedAttractions = ["383533", "383530", "323530", "323030", "353030", "393030"]
|
subscribedAttractions = ["383533", "383530", "323530", "323030", "353030", "393030"]
|
||||||
currentTimes = {}
|
currentTimes = {}
|
||||||
|
refreshTime = 30
|
||||||
|
|
||||||
# Send messagess via Discord Webhook
|
# Send messagess via Discord Webhook
|
||||||
def sendMessage(message):
|
def sendMessage(message):
|
||||||
|
|
@ -35,12 +36,15 @@ def checkTimes(subscribedAttractions):
|
||||||
for attraction in attractions:
|
for attraction in attractions:
|
||||||
if attraction["code"] in subscribedAttractions:
|
if attraction["code"] in subscribedAttractions:
|
||||||
if attraction["status"] == "opened":
|
if attraction["status"] == "opened":
|
||||||
|
refreshTime = 30
|
||||||
if not attraction["code"] in currentTimes: currentTimes[attraction["code"]] = attraction["waitingtime"];
|
if not attraction["code"] in currentTimes: currentTimes[attraction["code"]] = attraction["waitingtime"];
|
||||||
if currentTimes[attraction["code"]] > attraction["waitingtime"]:
|
if currentTimes[attraction["code"]] > attraction["waitingtime"]:
|
||||||
sendMessage(f"Waiting time of {attraction['name']} sank to {attraction['waitingtime']} Minutes!")
|
sendMessage(f"Waiting time of {attraction['name']} sank to {attraction['waitingtime']} Minutes!")
|
||||||
elif currentTimes[attraction["code"]] < attraction["waitingtime"]:
|
elif currentTimes[attraction["code"]] < attraction["waitingtime"]:
|
||||||
sendMessage(f"Waiting time for {attraction['name']} increased to {attraction['waitingtime']} Minutes!")
|
sendMessage(f"Waiting time for {attraction['name']} increased to {attraction['waitingtime']} Minutes!")
|
||||||
currentTimes[attraction["code"]] = attraction["waitingtime"]
|
currentTimes[attraction["code"]] = attraction["waitingtime"]
|
||||||
|
else:
|
||||||
|
refreshTime = 180
|
||||||
|
|
||||||
# Main Loop
|
# Main Loop
|
||||||
# Checks every 30 seconds for changes in the waiting times of the subscribed attractions
|
# Checks every 30 seconds for changes in the waiting times of the subscribed attractions
|
||||||
|
|
@ -51,5 +55,5 @@ if __name__ == '__main__':
|
||||||
while True:
|
while True:
|
||||||
checkTimes(subscribedAttractions)
|
checkTimes(subscribedAttractions)
|
||||||
print(f"Checked for updates at {time.strftime('%H:%M:%S', time.localtime())}")
|
print(f"Checked for updates at {time.strftime('%H:%M:%S', time.localtime())}")
|
||||||
time.sleep(30)
|
time.sleep(refreshTime)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue