Answer the question
In order to leave comments, you need to log in
How to make telegram bot always work?
I wrote a bot. It works, I sort of hosted it on https://www.pythonanywhere.com/user// but it doesn't do what I need. I need to make the bot always work
here is the code:
import pyowm
import telebot
owm = pyowm.OWM('3cc66d7b3233711f3dd379e246f01d34')
bot = telebot.TeleBot("5040545328:AAGLyu-I8rqQolyu8g", parse_mode=None)
@bot.message_handler(content_types =['text'])
def send_echo(message):
mgr = owm.weather_manager()
observation = mgr.weather_at_place( message.text )
w = observation.weather
temp = w.temperature('celsius')["temp"]
answer = "In town " + message.text + " now " + w.
answer += "The temperature is in the area right now" + str(temp) + "\n\n"
if temp < 10:
answer += "It's fucking cold, dress really warm!"
elif temp <20:
answer += "It's cold now, dress well so it doesn't get cold"
else:
answer += "The temperature is high, wear whatever"
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question