0
from telegram.ext import CallbackContext    
from telegram.ext import Updater
from telegram.ext import Filters
from telegram.ext import MessageHandler
from telegram import ReplyKeyboardMarkup
from telegram import KeyboardButton



button = 'Кнопка'

def messagehandler (update: Update,conext: CallbackContext):
    reply_markup = ReplyKeyboardMarkup(
        keyboard=[
               [
        KeyboardButton(text=button)
               ],   
        ],
        resize_keyboard = True,
        ),
    update.message.reply_text(
        text='Привет',
        reply_markup = reply_markup,
        )


def main ():
    print('start')
    updater = Updater(
       token = '1316145158:AAF2hFXftyoA0rPbv4b_I1rTFMca',
       use_context=True,)
    updater.dispatcher.add_handler(MessageHandler(filters=Filters.all, callback= messagehandler))
    updater.start_polling()
    updater.idle()

if __name__=='__main__':
    main()
      ```


Что делать?
2
  • Может хоть токен скроете? Хотя уже лучше делать новый.
    – Kers
    12 дек 2020 в 17:39
  • 1
    Я удалил последние несколько символов. Ничего страшного не будет
    – SwiftBike
    12 дек 2020 в 17:40

1 ответ 1

0

Наткнулся на подобную ошибку. Вот решение.

Вместо ReplyKeyboardMarkup следует использовать types.ReplyKeyboardMarkup:

keyboard_markup = types.ReplyKeyboardMarkup(resize_keyboard = True,)
keyboard_markup.add(types.KeyboardButton(text=button))

update.message.reply_text(
    text='Привет',
    reply_markup=reply_markup,
)

https://github.com/aiogram/aiogram/blob/dev-2.x/examples/regular_keyboard_example.py

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.