Answer the question
In order to leave comments, you need to log in
Is it possible to make a stop command?
How can I make it stop the execution of a command?
I write /pogoda and it always reacts to the words Moscow, etc. how can I make the bot stop responding to the words with the /stop command?
(What exactly this function does not react to words)
For example: I write /pogoda, then I write in which city I find out the info and write the /stop command, and if I write Moscow later, nothing will happen
(I don’t rummage for Python at all, I watched 1 video, now I’m trying to learn , I searched everywhere for a solution and through if elif, true false nothing helped)
import telebot
from pyowm import OWM
from pyowm.utils.config import get_default_config
config_dict = get_default_config()
config_dict['language'] = 'ru'
bot = telebot.TeleBot("token", parse_mode=None)
owm = OWM( 'token', config_dict )
@bot.message_handler(commands=['pogoda'])
def send_something(message):
pass
a = ( "В каком городе?" )
bot.send_message( message.chat.id, a )
@bot.message_handler(func=lambda message: True )
def echo_all(message):
mgr = owm.weather_manager()
observation = mgr.weather_at_place( message.text )
w = observation.weather
temp = w.temperature('celsius')["temp"]
w = w.detailed_status
answer = "В городе " + message.text + " сейчас " + w + "\n"
answer += "Температура: " + str(temp) + "\n"
if temp < 10:
answer += ("Ппц как холодно")
elif temp < 20:
answer += ("Холодно но не очень")
elif temp < 30:
answer += ( "Жарко" )
else:
print(Ошибка)
bot.send_message(message.chat.id, answer)
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