SHARE
TWEET

Untitled

a guest Jan 21st, 2020 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pyowm
  2. import telebot
  3.  
  4. owm = pyowm.OWM('57f25239a4bb74e4dd881fa522bb92db', language='ru')
  5.  
  6. bot = telebot.TeleBot("994380882:AAFnYrRI3BCUO3ENvCA96o6pQ2ZIwg23VnA")
  7.  
  8. @bot.message_handler(content_types=['text'])
  9. def send_echo(message):
  10.     observation = owm.weather_at_place( message.text )
  11.     w = observation.get_weather()
  12.     temp = w.get_temperature('celsius')["temp"]
  13.  
  14.     answer = "В городе " + message.text + " сейчас " + w.get_detailed_status() + "\n"
  15.     answer += "Температура сейчас в районе " + str(temp) + "\n\n"
  16.  
  17.     if temp < 10:
  18.         answer += "Сейчас очень холодно, одевайся тепло."
  19.     elif temp < 20:
  20.         answer += "Сейчас прохладно, одевайся потеплее."
  21.     elif temp > 20:
  22.         answer += "Сейчас тепло, одейвайся как хочешь."
  23.  
  24.  
  25.     bot.send_message(message.chat.id, answer)
  26.    
  27. bot.polling( none_stop = True )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top