@bot.message_handler(commands=['start'])
def start_message(message):
keyboard = telebot.types.ReplyKeyboardMarkup(True)
keyboard.row('Погода', 'Поговори со мной')
bot.send_message(message.chat.id, 'Привет!', reply_markup=keyboard)
@bot.message_handler(content_types = ["text"])
def send_msg(message):
if message.text == 'Погода':
bot.send_message(message.chat.id, "Введите город");
bot.register_next_step_handler(message, send_weather);
elif message.text == 'Поговори со мной':
bot.send_message(message.chat.id, "Напиши мне");
bot.register_next_step_handler(message, send_echo);
def send_weather(message):
observation = mgr.weather_at_place (message.text)
w = observation.weather
temp = w.temperature('celsius')["temp"]
wind = w.wind()["speed"]
answer = "В городе " + message.text + " сейчас " + w.detailed_status + ".\n" "За окном " + str(int(temp)) + " градусов.\n" "Скорость ветра " + str(wind) + " м/с."
bot.send_message(message.chat.id, answer)
def send_echo (message):
bot.send_message (message.chat.id, message.text)
bot.polling (none_stop = True)