Отправка пользователю сообщения ботом
Пишу простенького бота, подскажите, как его дописать таким образом, чтобы при нажатии на кнопку консультация, он отправлял любое рандомное сообщение конкретному пользователю? Пробовал
bot.send_message(id юзера, 'текст')
Но он возвращает ошибку
Threaded polling exception: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: chat not found
Вот код бота:
import telebot
from telebot import types
bot = telebot.TeleBot('6542913554:AAEPRwpdyTMc499Egpqc1j38jYCU-zLA2G4')
@bot.message_handler(commands=['start'])
def send_welcome(message):
markup = types.ReplyKeyboardMarkup(row_width=2)
item1 = types.KeyboardButton("Меню")
item2 = types.KeyboardButton("Консультация")
markup.add(item1, item2)
bot.send_message(message.chat.id, "Что вас интересует?", reply_markup=markup)
@bot.message_handler(func=lambda message: True)
def handle_level(message):
if message.text == "Меню":
markup = types.ReplyKeyboardMarkup(row_width=2)
item1 = types.KeyboardButton("Наши преимущества")
item2 = types.KeyboardButton("Процесс услуги")
item3 = types.KeyboardButton("Стоимость услуги")
item4 = types.KeyboardButton("Сделать самому")
item5 = types.KeyboardButton("Консультация")
markup.add(item1, item2, item3, item4, item5)
bot.send_message(message.chat.id, "Меню:", reply_markup=markup)
if message.text == "Наши преимущества":
markup = types.ReplyKeyboardMarkup(row_width=2)
bot.send_message(message.chat.id, "преимущества:", reply_markup=markup)
if message.text == "Процесс услуги":
markup = types.ReplyKeyboardMarkup(row_width=2)
bot.send_message(message.chat.id, "процесс:", reply_markup=markup)
if message.text == "Стоимость услуги":
markup = types.ReplyKeyboardMarkup(row_width=2)
bot.send_message(message.chat.id, "Стоимость:", reply_markup=markup)
if message.text == "Сделать самому":
markup = types.ReplyKeyboardMarkup(row_width=2)
bot.send_message(message.chat.id, "Сделать:", reply_markup=markup)
elif message.text == "Консультация":
markup = types.ReplyKeyboardMarkup(row_width=2)
bot.send_message(message.chat.id, "Консультация", reply_markup=markup)
bot.polling()```