Answer the question
In order to leave comments, you need to log in
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()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question