1
import pyowm
import telebot
import config


owm = pyowm.OWM('977177690:AAHGtD3f9BGUSLOQTDwDnHdKNVFlyWJmi4c', language = "ru")
bot = telebot.TeleBot(config.TOKEN)

@bot.message_handler(content_types=['text'])
def send_echo(message):
    observation = owm.weather_at_place( message.text )
    w = observation.get_weather()
    temp = w.get_temperature('celsius')["temp"]
    wind = w.get_wind()["speed"]
    humidity = w.get_humidity()

    answer = "В " + message.text + " сейчас " + str(temp) + " градусов по Цельсию" + "\n"
    answer += "Скорость ветра " + str(wind) + " м/с"
    answer += "Влажность " + str(humidity) + " %"

    temp_1 = round(temp)

    if temp_1 in range(-50,-26):
        answer += "Колотун 0_0, надевай валенки, маж харю жиром"
    if temp_1 in range(-25,-20):
        answer += "Не забудь варежки!"
    if temp_1 in range(-19,-10):
        answer += "Зябко, но жить можно"
    if temp_1 in range(-9,0):
        answer += "Можно и прогуляться"
    if temp_1 in range(1,10):
        answer += "Хорошая погода, но лёгкую куртку стоит одеть"
    if temp_1 in range(11,18):
        answer += "оооо, тепленько"
    if temp_1 in range(19,25):
        answer += "Время шортиков!"
    if temp_1 in range(25,40):
        answer += "Держись ближе к кондёру!"

    bot.send_message(message.chat.id, answer)

bot.polling( none_stop = True )
1
  • 1
    скорее всего прокси нужно подключить
    – krytoy4el
    7 апр 2020 в 16:29

1 ответ 1

0

Надо vpn включить или прокси, в настройках vpn ставь не Россию

1
  • Благодарю, помогло) 8 апр 2020 в 9:45

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.