mirror of
https://github.com/michivonah/themepark-alerts.git
synced 2025-12-22 20:36:27 +01:00
updated script to detected changes instead of fixed limits
This commit is contained in:
parent
5571ae24d2
commit
4c47182500
1 changed files with 10 additions and 5 deletions
15
main.py
15
main.py
|
|
@ -8,7 +8,7 @@ load_dotenv()
|
||||||
|
|
||||||
# Global defintions
|
# Global defintions
|
||||||
subscribedAttractions = ["383533", "383530", "323530", "323030", "353030", "393030"]
|
subscribedAttractions = ["383533", "383530", "323530", "323030", "353030", "393030"]
|
||||||
waitingtimeAlert = 30
|
currentTimes = {}
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
def sendMessage(message):
|
def sendMessage(message):
|
||||||
|
|
@ -16,7 +16,7 @@ def sendMessage(message):
|
||||||
webhook = DiscordWebhook(url=webhookUrl, content=message)
|
webhook = DiscordWebhook(url=webhookUrl, content=message)
|
||||||
response = webhook.execute()
|
response = webhook.execute()
|
||||||
|
|
||||||
def checkTimes(subscribedAttractions, alertlimit):
|
def checkTimes(subscribedAttractions):
|
||||||
endpoint = "https://api.wartezeiten.app/v1/waitingtimes"
|
endpoint = "https://api.wartezeiten.app/v1/waitingtimes"
|
||||||
|
|
||||||
header = {
|
header = {
|
||||||
|
|
@ -29,13 +29,18 @@ def checkTimes(subscribedAttractions, alertlimit):
|
||||||
attractions = result
|
attractions = result
|
||||||
for attraction in attractions:
|
for attraction in attractions:
|
||||||
if attraction["code"] in subscribedAttractions:
|
if attraction["code"] in subscribedAttractions:
|
||||||
if attraction["waitingtime"] < waitingtimeAlert and attraction["status"] == "opened":
|
if attraction["status"] == "opened":
|
||||||
sendMessage(f"Waiting time of {attraction['name']} less than {waitingtimeAlert} Minutes!")
|
if not attraction["code"] in currentTimes: currentTimes[attraction["code"]] = attraction["waitingtime"];
|
||||||
|
if currentTimes[attraction["code"]] > attraction["waitingtime"]:
|
||||||
|
sendMessage(f"Waiting time of {attraction['name']} sank to {attraction['waitingtime']} Minutes!")
|
||||||
|
elif currentTimes[attraction["code"]] < attraction["waitingtime"]:
|
||||||
|
sendMessage(f"Waiting time for {attraction['name']} increased to {attraction['waitingtime']} Minutes!")
|
||||||
|
currentTimes[attraction["code"]] = attraction["waitingtime"]
|
||||||
|
|
||||||
# Main
|
# Main
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
while True:
|
while True:
|
||||||
checkTimes(subscribedAttractions, waitingtimeAlert)
|
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(30)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue