I
I
Ivan Ok2019-04-14 00:18:46
Python
Ivan Ok, 2019-04-14 00:18:46

Why does the Python Telegram bot keyboard work?

what you want: user 1 enters the bot, selects "I want to have breakfast" on the keyboard - then on the keyboard "Easy breakfast", then writes a question or presses "no questions" on the keyboard and this information is sent to user 2
what now - sends only information from 1 keyboard
was an attempt to make an inline keyboard, but it was not possible to send information from it at all.
here is the code

import telebot
from telebot import types
import const

bot = telebot.TeleBot(const.API_TOKEN) #файл с токеном 

@bot.message_handler(commands=['start', 'help'])
def send_welcome(message):
  bot.reply_to(message, "Привет! Что хочешь поесть? \n\n Мануал  ", reply_markup=markup_menu )

@bot.message_handler(content_types=["text"])  # попытка переслать сообщения боту который отправил пользователь 1 пользователю 2 
def some_funtion(message):  # Название функции неважно
    bot.send_message('id диалога с пользователем 2', message.text)

markup_menu = types.ReplyKeyboardMarkup (resize_keyboard=True, row_width=1)

btn_zavtrak= types.KeyboardButton ('Хочу позавтракать')

markup_menu.add( btn_zavtrak)

@bot.message_handler(func=lambda message: True)
def echo_all(message):
    if  message.text == "Хочу позавтракать":
        bot.reply_to(message, 'Варианты завтраков', reply_markup=markup_zavtrak )
    else:
        bot.reply_to(message, 'Ваш запрос принят, обработка займет не более 5 мин.')


markup_zavtrak = types.ReplyKeyboardMarkup (resize_keyboard=True, row_width=3)
btn_legkii_zavtrak = types.KeyboardButton ('Легкий')

markup_zavtrak.add(btn_legkii_zavtrak)


markup_inline_otvet = types.InlineKeyboardMarkup()
btn_otvet = types.InlineKeyboardButton ('Вопросов нет',callback_data ='Вопросов нет')
markup_inline_otvet.add(btn_otvet)


bot.polling()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question