I've a message handler that respond to a command in a Bot application written in python3 with the library Aiogram.
I can receive from the application the message I send to the BOT, but I would like to exclude the command (via config possibly, not parsing the string). Maybe it is in the documentation, but currently I could not find the answer.
To be clear with an example, if I type to my TelegramBot
/my_command text
where this is my code in the python3 application
@dispatcher.message_handler(commands=['my_command'])
async def echo(message: types.Message):
I would like to receive from the message_handler in the message types.Message variable the string text and not /my_command text.
Thanks a lot
The function to extract only the arguments of a command is get_args():
@dispatcher.message_handler(commands=['my_command'])
async def echo(message: types.Message):
arguments = message.get_args()
await message.reply(arguments)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With