如何在Aiogram的调度程序中从message_handler中排除/命令?

axe*_*xel 4 python command python-3.x telegram telegram-bot

我有一个消息处理程序,它响应使用 python3 和 Aiogram 库编写的 Bot 应用程序中的命令。

我可以从应用程序接收发送到 BOT 的消息,但我想排除该命令(可能通过配置,而不是解析字符串)。也许它在文档中,但目前我找不到答案。

为了清楚起见,如果我输入我的 TelegramBot

/my_command text
Run Code Online (Sandbox Code Playgroud)

这是我在 python3 应用程序中的代码

@dispatcher.message_handler(commands=['my_command'])
async def echo(message: types.Message):
Run Code Online (Sandbox Code Playgroud)

我想从message types.Message变量中的 message_handler 接收字符串text而不是/my_command text

多谢

axe*_*xel 7

仅提取命令参数的函数是get_args()

@dispatcher.message_handler(commands=['my_command'])
async def echo(message: types.Message):
    arguments = message.get_args()
    await message.reply(arguments)
Run Code Online (Sandbox Code Playgroud)