F
F
First Name Last Name2021-07-25 09:53:21
Python
First Name Last Name, 2021-07-25 09:53:21

Aiogram BadRequest?

Good day. I wanted to create a test bot on Aiogram, and when I added Inline buttons, it gives me

mistake
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 keyboards.py
token = "Мой токен"

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)


Thanks for your reply in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-07-25
@alikk_python

It's written

text buttons are unallowed in the inline keyboard

Inline buttons must have at least one optional field, callback_dataor urllet's say.
https://core.telegram.org/bots/api#inlinekeyboardbutton
If you need text buttons - replykeyboard

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question