admin管理员组

文章数量:1279212

I have a bot with one command and a callback. In the first command, there is a block of code that I need to call after the callback. How can I do it so that I don't just copy it to the callback?

@dp.message(CommandStart())
async def bot_start_handler(message: Message) -> None:
    #some code
    # .....
    await message.answer(message.from_user.id)

@dp.callback_query(F.data == "continue")
async def bot_get_sign(callback: types.CallbackQuery):
    # some code
    functionA()

@dp.callback_query(F.data.startswith('q_'))
async def sign_step(callback: types.CallbackQuery):
    await callback.message.delete()

    await bot_start_handler() # There i need to run bot_start_handler(), but how?

I looked in the guides and documentation about it, but I couldn't find it. I need to run the content of bot_start_handler function from sign_step.

I tried to put callback.message in bot_start_handler(), 1 function got bot information (username, id and other), but I need user information.

await bot_start_handler(callback.message)

本文标签: pythonHow to run the content of a function from another function with a callbackStack Overflow