Answer the question
In order to leave comments, you need to log in
Error when starting a telegram bot?
telegram bot gives error when starting
F:\Python>2228.py
File "F:\Python\2228.py", line 3
import telebot
^
SyntaxError: invalid syntax
import pyowm
@util.async_dec
import telebot
owm = pyowm.OWM('85968f9b899f176aa48e768a59ad27ee', language = "ru")
bot = telebot.TeleBot("960904533:AAFbTAtQk4-dqI2fvxXoIYEtFBB2c7TEvf8")
@bot.message_handler(conntent_types=['text'])
def send_echo(message):
observation = owm.weather_at_place(place)
w = observation.get_weather()
temp = w.get_temperature('celsius')["temp"]
answer = "В городе " + place + " сейчас " + w.get_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)
Answer the question
In order to leave comments, you need to log in
Obviously needs to be removed @util.async_dec
before importing telebot
.
I also strongly recommend updating the tokens that you have successfully released to the public.
And yet, there is a special tag for inserting code (paragraph 3.8 of the rules). For laying out an indent-dependent language without indents, you can go to a separate boiler :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question