Ответы пользователя по тегу Боты
  • Можно ли сделать кнопку inline, в telegram боте в две строки?

    @RiderMC
    Конечно можно.
    Вот пример:
    import telebot
    from config import TOKEN
    
    bot = telebot.TeleBot(TOKEN)
    
    @bot.message_handler(commands=['start'])
    def process_start(message):
        keyboard = telebot.types.ReplyKeyboardMarkup(True)
        keyboard.row('Выбери меня')
        msg = bot.send_message(message.chat.id, text = 'Нажми кнопку в меню', reply_markup = keyboard )
    
    
    @bot.message_handler(content_types = ['text'])
    def step1(message):
        menu1 = telebot.types.InlineKeyboardMarkup()
        menu1.add(telebot.types.InlineKeyboardButton(text = 'Первая кнопка', callback_data ='first'))
        menu1.add(telebot.types.InlineKeyboardButton(text = 'Вторая кнопка', callback_data ='second'))
    
        if message.text == 'Выбери меня':
            msg = bot.send_message(message.chat.id, text ='Нажми первую inline кнопку', reply_markup = menu1)
            bot.register_next_step_handler(msg, step2)
    
    
    @bot.callback_query_handler(func=lambda call: True)
    def step2(call):
        menu2 = telebot.types.InlineKeyboardMarkup()
        menu2.add(telebot.types.InlineKeyboardButton(text = 'Третья кнопка', callback_data ='third'))
        menu2.add(telebot.types.InlineKeyboardButton(text = 'Четвертая кнопка', callback_data ='fourth'))
    
        if call.data == 'first':
            msg = bot.send_message(call.message.chat.id, 'Нажми третью кнопку', reply_markup = menu2)
            bot.register_next_step_handler(msg, step3)
    
    def step3(call):
        if call.data == 'third':
            msg = bot.send_message(call.message.chat.id, 'Конец')
        else:
            pass
      
    
    bot.polling(none_stop=True)

    5ec3ca5529bde760985712.png

    Взял отсюда: https://qna.habr.com/q/774821
    Ответ написан
    1 комментарий
  • Как сделать бота с таким функционалом?

    @RiderMC
    Попробуйте зайти в BotFather
    Выбрать нужного бота
    Bot Settings > Group Privacy > нажать на 'turn off'
    Ответ написан
    Комментировать