From 08b7021ca080d160de841e92c9b3e228822f4158 Mon Sep 17 00:00:00 2001 From: Sergey Date: Sat, 20 Jan 2018 02:18:19 +0300 Subject: [PATCH] Create regexp_commands_filter_example.py --- examples/regexp_commands_filter_example.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 examples/regexp_commands_filter_example.py diff --git a/examples/regexp_commands_filter_example.py b/examples/regexp_commands_filter_example.py new file mode 100644 index 00000000..3cd859db --- /dev/null +++ b/examples/regexp_commands_filter_example.py @@ -0,0 +1,16 @@ +from aiogram import Bot, types +from aiogram.dispatcher import Dispatcher, filters +from aiogram.utils import executor + +bot = Bot(token='TOKEN') +dp = Dispatcher(bot) + + +@dp.message_handler(filters.RegexpCommandsFilter(regexp_commands=['item_([0-9]*)'])) +async def send_welcome(message: types.Message): + regexp_command = message.conf['regexp_command'] + await message.reply("You have requested an item with number: {}".format(regexp_command.group(1))) + + +if __name__ == '__main__': + executor.start_polling(dp)