Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. from pyowm import OWM
  2. owm = pyowm.OWM('6d00d1d4e704068d70191bad2673e0cc', language="ru")
  3.  
  4. @bot.on.message_both('/weather <place>')
  5. @bot.on.message_both('погода <place>')
  6. @bot.on.message_both('Погода <place>')
  7. async def weather(ans: Message, place, encoding='utf-8'):
  8. try:
  9. observation = owm.weather_at_place(place)
  10. print(observation)
  11. w = observation.get_weather()
  12. temp = w.get_temperature('celsius')["temp"]
  13. windy = w.get_wind()['speed']
  14. await ans(f {place.upper()}\n{smile} | Сейчас {w.get_detailed_status()}\n\n🌡 >> {temp}°C\n🌬 >> {windy} м/с\n💧 >> {w.get_humidity()}%')
  15. except pyowm.exceptions.api_response_error.NotFoundError as error:
  16. await ans(f'Ошибка! Объект <<{place}>> не найден. Подробная ошибка:\n<<{error}>>')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement