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
版权声明:本文标题:python - How to run the content of a function from another function with a callback? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741268538a2368897.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论