K
K
killer_bean2021-11-24 18:23:13
Python
killer_bean, 2021-11-24 18:23:13

How to fix nameerror?

Having started to study python, I tried to write a bot for a cart. Earned only echo bot. I write further. Help, what's wrong?
the code itself:

import pyowm
import telebot


from pyowm import OWM
from pyowm.utils import config
from pyowm.utils import timestamps

bot = telebot.TeleBot("2108906770:AAF3Va4YQEguBzqrT48-ZlqH8aCYk7AsWVE", parse_mode=None) # You can set parse_mode by default. HTML or MARKDOWN

owm = OWM('060639194331733e7cb84298692091fc')
#mgr = owm.weather_manager()

content_types=["text"]
@bot.message_handler(content_types=['text'])
def send_echo(message):
  
  observation = mgr.weather_at_place( message.text )
  w = observation.weather
  tp = w.get_temperature('celsius')["temp"]
  weather = w.get_detailed_status
  
  answ = 'Сейчас в городе ' + message.text + ' ' + weather + ', \n' + str(tp) + ' градусов.\n'
  answ += '\n . '

if tp < 0:
  answ += 'Тут прохладно.'
elif tp < -10:
  answ += 'Здесь очень холодно!'
else:
  answ += 'Температура вроде норм, делай что хочешь.'

  #bot.reply_to(message, message.text)
  bot.send_message(message.chat.id, message.text)

bot.infinity_polling()

619e58bdceb5d599690797.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question