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
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

gotify.py 1.1 KiB

123456789101112131415161718192021222324252627282930313233
  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_today = weather_today()
  12. weather_today = Translation[weather_today]
  13. send_notif("Meteo d'aujourd'hui", "Le temps sera %s, Il y aura une température moyenne de %s °C" % (weather_today, get_temp_today()) )
  14. def send_notification_for_tomorrow():
  15. weather_tomorrow = weather_tomorrow()
  16. weather_tomorrow = Translation[weather_tomorrow]
  17. send_notif("Meteo de demain", "Le temps sera %s, Il y aura une température moyenne de %s °C" % (weather_tomorrow, get_temp_tomorrow()) )
  18. if __name__ == '__main__':
  19. try :
  20. main()
  21. except :
  22. send_notif("Erreur", "Une erreur s'est produite durant l'execution du script")
  23. main()