@alikk_python
Кратко о себе

Aiogram BadRequest?

Доброго времени суток. Хотел создать тестового бота на Aiogram, а когда добавил Inline кнопки, мне выдает
ошибку
Task exception was never retrieved
future: exception=BadRequest("Can't parse inline keyboard button: text buttons are unallowed in the inline keyboard")>
Traceback (most recent call last):
File "D:\Program Files\Python38\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 417, in _process_polling_updates
for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
File "D:\Program Files\Python38\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 238, in process_updates
return await asyncio.gather(*tasks)
File "D:\Program Files\Python38\lib\site-packages\aiogram\dispatcher\handler.py", line 116, in notify
response = await handler_obj.handler(*args, **partial_data)
File "D:\Program Files\Python38\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 259, in process_update
return await self.message_handlers.notify(update.message)
File "D:\Program Files\Python38\lib\site-packages\aiogram\dispatcher\handler.py", line 116, in notify
response = await handler_obj.handler(*args, **partial_data)
File "bot.py", line 13, in hello
await message.answer("Выберите язык / Choose a language", reply_markup=kb.chooseLangAdd)
File "D:\Program Files\Python38\lib\site-packages\aiogram\types\message.py", line 359, in answer
return await self.bot.send_message(
File "D:\Program Files\Python38\lib\site-packages\aiogram\bot\bot.py", line 314, in send_message
result = await self.request(api.Methods.SEND_MESSAGE, payload)
File "D:\Program Files\Python38\lib\site-packages\aiogram\bot\base.py", line 208, in request
return await api.make_request(self.session, self.server, self.__token, method, data, files,
File "D:\Program Files\Python38\lib\site-packages\aiogram\bot\api.py", line 140, in make_request
return check_result(method, response.content_type, response.status, await response.text())
File "D:\Program Files\Python38\lib\site-packages\aiogram\bot\api.py", line 115, in check_result
exceptions.BadRequest.detect(description)
File "D:\Program Files\Python38\lib\site-packages\aiogram\utils\exceptions.py", line 141, in detect
raise cls(description)
aiogram.utils.exceptions.BadRequest: Can't parse inline keyboard button: text buttons are unallowed in the inline keyboard


bot.py
from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
from aiogram.utils import executor

import keyboards as kb
from config import token

bot = Bot(token)
dp = Dispatcher(bot)

@dp.message_handler(commands=['start'])
async def hello(message: types.Message):
	await message.answer("Выберите язык / Choose a language", reply_markup=kb.chooseLangAdd)

if __name__ == '__main__':
	executor.start_polling(dp)


config.py
token = "Мой токен"

keyboards.py
from aiogram.types import ReplyKeyboardRemove, \
    ReplyKeyboardMarkup, KeyboardButton, \
    InlineKeyboardMarkup, InlineKeyboardButton

chooseLangButtonEN = InlineKeyboardButton('')
chooseLangButtonRU = InlineKeyboardButton('')

featuresButtonRU = InlineKeyboardButton('Возможности', callback_data='help')
featuresButtonEN = InlineKeyboardButton('Features', callback_data='help')

addToChatEN = InlineKeyboardButton('Add to chat')
addToChatRU = InlineKeyboardButton('Добавить в чат') 

chooseLangAdd = InlineKeyboardMarkup().row(chooseLangButtonEN).row(chooseLangButtonRU)


Спасибо за ответ заранее.
  • Вопрос задан
  • 182 просмотра
Решения вопроса 1
SoreMix
@SoreMix Куратор тега Python
yellow
Написано же
text buttons are unallowed in the inline keyboard


Инлайн кнопки должны иметь хотя бы одно опциональное поле, callback_data или url допустим.
https://core.telegram.org/bots/api#inlinekeyboardbutton

Если нужны текстовые кнопки - replykeyboard
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы