Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. @bot.message_handler(func=lambda c: c.startswith("!weather"))
  2. def weather(message):
  3. if len(message.text)>9:
  4. place = message.text[9:]
  5. observation = owm.weather_at_place(place)
  6. w = observation.get_weather()
  7. bot.send_message(message.chat.id, 'in {} is {} fahrenheit and it is {}.'.format(place,str(w.get_temperature('fahrenheit')['temp']),str(w.get_detailed_status()))
  8. else:
  9. bot.send_message(message.chat.id, "You must be !weather country/city")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement