Récupérer la météo et l'envoyer par Gotify Le but de ce projet est avant-tout de tester Gotify et voir s'il peut potentiellement remplacer Telegram dans la plupart de mes projets qui nécessitent des notifications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gotify.py 987 B

1234567891011121314151617181920212223242526272829
  1. import requests #pip install requests
  2. from config import Gotify, Translation
  3. from get_weather import weather_tomorrow, weather_today, get_temp_today, get_temp_tomorrow
  4. def send_notif(title, message):
  5. resp = requests.post(Gotify['URL'] + '?token=' + Gotify['token_gotify'] , json={
  6. "message": message,
  7. "priority": 2,
  8. "title": title
  9. })
  10. def send_notification_for_today():
  11. weather = str(Translation[weather_today()])
  12. send_notif("Meteo d'aujourd'hui", "Le temps sera %s, Il y aura une température moyenne de %s °C" % (weather, get_temp_today()) )
  13. def send_notification_for_tomorrow():
  14. weather = str(Translation[ weather_tomorrow()])
  15. send_notif("Meteo de demain", "Le temps sera %s, Il y aura une température moyenne de %s °C" % (weather, get_temp_tomorrow()) )
  16. if __name__ == '__main__':
  17. try :
  18. main()
  19. except :
  20. send_notif("Erreur", "Une erreur s'est produite durant l'execution du script")
  21. main()