From 747c87631ed28dbf6da49ff48b86cdcd3bde0457 Mon Sep 17 00:00:00 2001 From: Suren Khorenyan Date: Sun, 11 Aug 2019 16:26:29 +0300 Subject: [PATCH] Refactor examples/regexp_commands_filter_example.py --- examples/regexp_commands_filter_example.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/examples/regexp_commands_filter_example.py b/examples/regexp_commands_filter_example.py index 86ccba55..05de9dd8 100644 --- a/examples/regexp_commands_filter_example.py +++ b/examples/regexp_commands_filter_example.py @@ -2,14 +2,28 @@ from aiogram import Bot, types from aiogram.dispatcher import Dispatcher, filters from aiogram.utils import executor -bot = Bot(token='TOKEN') + +bot = Bot(token='BOT_TOKEN_HERE', parse_mode=types.ParseMode.HTML) dp = Dispatcher(bot) @dp.message_handler(filters.RegexpCommandsFilter(regexp_commands=['item_([0-9]*)'])) async def send_welcome(message: types.Message, regexp_command): - await message.reply("You have requested an item with number: {}".format(regexp_command.group(1))) + await message.reply(f"You have requested an item with id {regexp_command.group(1)}") + + +@dp.message_handler(commands='start') +async def create_deeplink(message: types.Message): + bot_user = await bot.me + bot_username = bot_user.username + deeplink = f'https://t.me/{bot_username}?start=item_12345' + text = ( + f'Either send a command /item_1234 or follow this link {deeplink} and then click start\n' + 'It also can be hidden in a inline button\n\n' + 'Or just send /start item_123' + ) + await message.reply(text, disable_web_page_preview=True) if __name__ == '__main__': - executor.start_polling(dp) + executor.start_polling(dp, skip_updates=True)