Обработка RequestContactButton #24
Answered
by
4qwerty1
stanislavsibirtsev
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
4qwerty1
Feb 4, 2026
Replies: 1 comment 1 reply
-
|
Привет. Если я правильно понял вопрос, то "несколько разных обработчиков под различные случаи RequestContactButton" можно сделать c использованием состояний. Будет что-то подобное: @dp.message_created(
F.message.body.attachments.len() > 0,
F.message.body.attachments[0].type == 'contact',
SomeStateGroup.some_state
)И для удобства добавить фильтр: class ContactFilter(BaseFilter):
async def __call__(self, event: UpdateUnion) -> bool:
if not isinstance(event, MessageCreated):
return False
attachments = event.message.body.attachments
if not attachments:
return False
return any(att.type == 'contact' for att in attachments) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
stanislavsibirtsev
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Привет.
Если я правильно понял вопрос, то "несколько разных обработчиков под различные случаи RequestContactButton" можно сделать c использованием состояний. Будет что-то подобное:
И для удобства добавить фильтр: