mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Deep-linking filter based on commands handler
This commit is contained in:
parent
beca19b5e2
commit
23f68628d5
1 changed files with 16 additions and 1 deletions
|
|
@ -93,8 +93,23 @@ class Command(Filter):
|
|||
|
||||
|
||||
class CommandStart(Command):
|
||||
def __init__(self):
|
||||
def __init__(self, deep_link=None):
|
||||
super(CommandStart, self).__init__(['start'])
|
||||
self.deep_link = deep_link
|
||||
|
||||
async def check(self, message: types.Message):
|
||||
check = await super(CommandStart, self).check(message)
|
||||
|
||||
if check and self.deep_link is not None:
|
||||
if not isinstance(self.deep_link, re.Pattern):
|
||||
return message.get_args() == self.deep_link
|
||||
|
||||
match = self.deep_link.match(message.get_args())
|
||||
if match:
|
||||
return {'deep_link': match}
|
||||
return False
|
||||
|
||||
return check
|
||||
|
||||
|
||||
class CommandHelp(Command):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue