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
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

34 行
1.1 KiB

  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()