csparpa / pyowm

A Python wrapper around the OpenWeatherMap web API
https://pyowm.readthedocs.io
MIT License
789 stars 171 forks source link

trying to add temperature to telegram bot #377

Closed f0resttt closed 3 years ago

f0resttt commented 3 years ago

import pyowm import telebot

owm = pyowm.OWM("4815694591339727dd4a1e2af59064ae") bot = telebot.TeleBot("1857465052:AAEeb3OjRbFwhuppShqWykJu60XXngaOF6Y")

@bot.message_handler(content_types=['text']) def send_echo(message): observation = owm.weather_at_place w = observation.weather temp = w.temperature('celsius')["temp"]

answer = "В городе " + place + " сейчас " + w.detailed_status + "\n"
answer += "Температура сейчас в районе " + str(temp) + "\n\n"

if  temp < 10:
    answer += "Сейчас ппц как холодно, одевайся тепло" 
elif temp < 20:
    answer += "Сейчас холодно" 
else:
    answer += "Температура норм" 

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

bot.polling( none_stop = True)

and error occurs

File "C:\pyth\forestt.py", line 25, in bot.polling( none_stop = True) File "C:\Users\DOOM\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot__init.py", line 514, in polling self.threaded_polling(none_stop, interval, timeout, long_polling_timeout) File "C:\Users\DOOM\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot__init.py", line 573, in threaded_polling raise e File "C:\Users\DOOM\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot__init.py", line 536, in threaded_polling self.worker_pool.raise_exceptions() File "C:\Users\DOOM\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\util.py", line 117, in raise_exceptions raise self.exception_info File "C:\Users\DOOM\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\util.py", line 69, in run task(*args, **kwargs) File "C:\pyth\forestt.py", line 9, in send_echo observation = owm.weather_at_place AttributeError: 'OWM' object has no attribute 'weather_at_place' any help?

csparpa commented 3 years ago

@f0resttt https://pyowm.readthedocs.io/en/latest/v3/faq.html#attributeerror-owm25-object-has-no-attribute-xxx

f0resttt commented 3 years ago

seems like i got it to work, thx \ close