from aiogram import types, Dispatcher
from aiogram.dispatcher.filters import Text
from keys.keying import game_keys
# @dp.message_handler(commands='game')
async def start_game(message: types.Message):
await message.answer('Выберите!', reply_markup=game_keys)
await message.delete()
# @dp.callback_query_handler(Text(startswith='word_'))
async def game_callback(call: types.CallbackQuery):
await call.message.answer(f'Вы выбрали {call.data.split("_")[1]}')
await call.message.delete()
await call.answer()
def register_handlers_client(dp: Dispatcher):
dp.register_message_handler(start_game, commands='game')
dp.callback_query_handler(game_callback, Text(startswith='word_'))
from aiogram import types, Dispatcher
from aiogram.dispatcher.filters import Text
from keys.keying import game_keys
@dp.message_handler(commands='game')
async def start_game(message: types.Message):
await message.answer('Выберите!', reply_markup=game_keys)
await message.delete()
@dp.callback_query_handler(Text(startswith='word_'))
async def game_callback(call: types.CallbackQuery):
await call.message.answer(f'Вы выбрали {call.data.split("_")[1]}')
await call.message.delete()
await call.answer()
def register_handlers_client(dp: Dispatcher):
dp.register_message_handler(start_game, commands='game')
dp.callback_query_handler(game_callback, Text(startswith='word_'))
from logic.config import dp
from aiogram.utils import executor
from logic.game import register_handlers_client
register_handlers_client(dp)
executor.start_polling(dp, skip_updates=True)
from aiogram import Bot
from aiogram import Dispatcher
bot = Bot(token='TOKEN')
dp = Dispatcher(bot)</spoiler>
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
nouns = InlineKeyboardButton(text='существительное', callback_data='word_nouns')
verb = InlineKeyboardButton(text='глагол', callback_data='word_verb')
adverbs = InlineKeyboardButton(text='наречие', callback_data='word_adverbs')
adjectives = InlineKeyboardButton(text='прилагательное', callback_data='word_adjectives')
game_keys = InlineKeyboardMarkup(row_width=2)
game_keys.add(nouns).add(adverbs).add(verb).add(adjectives)
register_*_handler
, в то время как для инлайн кнопки вызвали обычную функцию, которая должна являться декоратором. register_callback_query_handler()