# Диспетчер
storage = MemoryStorage()
dp = Dispatcher(storage=storage)
# Определяем состояния
class transferForm(StatesGroup):
waiting_for_username = State(),
waiting_for_cost = State()
@dp.message(F.text.lower() == "перевести")
async def transfer(message: types.Message):
cancel_kb = InlineKeyboardMarkup().add(InlineKeyboardButton('Отмена', callback_data='cancel'))
await transferForm.waiting_for_username.set() # Устанавливаем состояние ожидания username
await message.reply("Делитесь радостью с друзьями! Просто кликните на профиль в списке друзей или напишите сообщение, чтобы сделать им приятный сюрприз! Получайте бонусы и смотрите, как увеличивается ваша сеть!", reply_markup=cancel_kb)
@dp.message(state=transferForm.waiting_for_username)
async def transfer_process_username(message: types.Message, state):
cancel_kb = InlineKeyboardMarkup().add(InlineKeyboardButton('Отмена', callback_data='cancel'))
await state.update_data(username = message.text) # Сохраняем имя
await transferForm.waiting_for_username.set()
await message.reply("Введите сумму. Минмум 0.00001", reply_markup=cancel_kb)
@dp.message(state=transferForm.waiting_for_cost)
async def transfer_process_cost(message: types.Message, state):
await state.update_data(username = message.text) # Сохраняем имя
await transferForm.waiting_for_username.set()
Выдаёт:
Traceback (most recent call last):
File "/home/stas/Рабочий стол/aaxa/bot.py", line 98, in <module>
@dp.message(state=transferForm.waiting_for_username)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/stas/.local/lib/python3.12/site-packages/aiogram/dispatcher/event/telegram.py", line 138, in wrapper
self.register(callback, *filters, flags=flags, **kwargs)
File "/home/stas/.local/lib/python3.12/site-packages/aiogram/dispatcher/event/telegram.py", line 68, in register
raise UnsupportedKeywordArgument(
aiogram.exceptions.UnsupportedKeywordArgument: Passing any additional keyword arguments to the registrar method is not supported.
This error may be caused when you are trying to register filters like in 2.x version of this framework, if it's true just look at correspoding documentation pages.
Please remove the {'state'} arguments from this call.
(background on this error at: https://docs.aiogram.dev/en/dev-3.x/migration_2_to_3.html#filtering-events)