im new to python and now im working to telegram bot using aiogram, i want to make my commands without slashes "/" in front of my commands.
the code i use
@dp.message_handler(commands=["start", 'help'], commands_prefix='/')
async def welcome(message: types.Message):
await message.reply("Hello! I'm Humann!")
@dp.message_handler()
async def echo(message: types.Message):
await message.answer(f"you said {message.text}?")
executor.start_polling(dp)
i dont know how to remove slashes, anybody help pleaseπππ. i’ll apreciate it.
thanks
aiogram, fix telegram bot
2
Answers
Im prob. not the best person to answer, as Iv never coded in Py, but
maybe you can look for how to escape special character, such as
/
.I found this on W3:
https://www.w3schools.com/python/python_regex.asp
Maybe
d
could be helpful for you?if I understood correctly:
you could simply filter messages by text for example, you send to bot
bot will answer:
And this looks like command without slash
!!! Remember to paste this before all other text-messages handlers, or if you paste it last – your message will go to echo function (because it filters all text messages.
Aiogram has a lot of variables for commands (CommandStart, CommandSettings)? you should see all in aiogram filters documentation
Commands is better when you set default_commands in bot and next you could see and use them all when you press menu button (in private chat with bot)