Skip to content
Discussion options

You must be logged in to vote

Привет.

Если я правильно понял вопрос, то "несколько разных обработчиков под различные случаи 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)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@stanislavsibirtsev
Comment options

Answer selected by stanislavsibirtsev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants