mirror of
https://github.com/michivonah/themepark-alerts.git
synced 2025-12-22 20:36:27 +01:00
create script for alerting to discord
This commit is contained in:
parent
51dccb0898
commit
9f8df3931b
1 changed files with 25 additions and 10 deletions
25
main.py
25
main.py
|
|
@ -5,6 +5,17 @@ from discord_webhook import DiscordWebhook
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
|
# Global defintions
|
||||||
|
subscribedAttractions = ["383533", "383530", "323530", "323030", "353030", "393030"]
|
||||||
|
waitingtimeAlert = 30
|
||||||
|
|
||||||
|
# Functions
|
||||||
|
def sendMessage(message):
|
||||||
|
webhookUrl = os.getenv('DISCORD_WEBHOOK')
|
||||||
|
webhook = DiscordWebhook(url=webhookUrl, content=message)
|
||||||
|
response = webhook.execute()
|
||||||
|
|
||||||
|
def checkTimes(subscribedAttractions, alertlimit):
|
||||||
endpoint = "https://api.wartezeiten.app/v1/waitingtimes"
|
endpoint = "https://api.wartezeiten.app/v1/waitingtimes"
|
||||||
|
|
||||||
header = {
|
header = {
|
||||||
|
|
@ -12,11 +23,15 @@ header = {
|
||||||
"park":"europapark"
|
"park":"europapark"
|
||||||
}
|
}
|
||||||
|
|
||||||
req = requests.get(url = endpoint, params = header)
|
req = requests.get(url = endpoint, headers = header)
|
||||||
|
|
||||||
result = req.json()
|
result = req.json()
|
||||||
|
attractions = result
|
||||||
|
for attraction in attractions:
|
||||||
|
if attraction["code"] in subscribedAttractions:
|
||||||
|
if attraction["waitingtime"] < waitingtimeAlert and attraction["status"] == "opened":
|
||||||
|
sendMessage(f"Waiting time of {attraction['name']} less than {waitingtimeAlert} Minutes!")
|
||||||
|
|
||||||
webhookUrl = os.getenv('DISCORD_WEBHOOK')
|
# Main
|
||||||
|
if __name__ == '__main__':
|
||||||
|
checkTimes(subscribedAttractions, waitingtimeAlert)
|
||||||
|
|
||||||
webhook = DiscordWebhook(url=webhookUrl, content=result["error"])
|
|
||||||
response = webhook.execute()
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue