0

получил entity чата:

ChatFull(
    full_chat=ChannelFull(
        id=1116621739,
        about='DCx - Managed Global Payment Blockchain',
        read_inbox_max_id=0,
        read_outbox_max_id=0,
        unread_count=0,
        chat_photo=Photo(
            id=1633033170115995569,
            access_hash=8984998890296788523,
            date=datetime.datetime(2017, 11, 27, 21, 2, 24, tzinfo=datetime.timezone.utc),
            sizes=[
                PhotoSize(
                    type='a',
                    location=FileLocation(
                        dc_id=4,
                        volume_id=439017094,
                        local_id=43782,
                        secret=-8457972351196598110
                    ),
                    w=160,
                    h=160,
                    size=11022
                ),
                PhotoSize(
                    type='b',
                    location=FileLocation(
                        dc_id=4,
                        volume_id=439017094,
                        local_id=43783,
                        secret=2676694934137458113
                    ),
                    w=320,
                    h=320,
                    size=23926
                ),
                PhotoSize(
                    type='c',
                    location=FileLocation(
                        dc_id=4,
                        volume_id=439017094,
                        local_id=43784,
                        secret=-7123110236713885533
                    ),
                    w=640,
                    h=640,
                    size=69692
                ),
            ],
            has_stickers=False
        ),
        notify_settings=PeerNotifySettings(
            show_previews=None,
            silent=None,
            mute_until=None,
            sound=None
        ),
        exported_invite=ChatInviteEmpty(
        ),
        bot_info=[
        ],
        can_view_participants=False,
        can_set_username=False,
        can_set_stickers=False,
        hidden_prehistory=False,
        participants_count=10,
        admins_count=None,
        kicked_count=None,
        banned_count=None,
        migrated_from_chat_id=None,
        migrated_from_max_id=None,
        pinned_msg_id=None,
        stickerset=None,
        available_min_id=None
    ),
    chats=[
        Channel(
            id=1116621739,
            title='DCX Tokensale',
            photo=ChatPhoto(
                photo_small=FileLocation(
                    dc_id=4,
                    volume_id=439017094,
                    local_id=43782,
                    secret=-8457972351196598110
                ),
                photo_big=FileLocation(
                    dc_id=4,
                    volume_id=439017094,
                    local_id=43784,
                    secret=-7123110236713885533
                )
            ),
            date=datetime.datetime(2017, 10, 6, 2, 26, 5, tzinfo=datetime.timezone.utc),
            version=0,
            creator=False,
            left=True,
            editor=False,
            broadcast=True,
            verified=False,
            megagroup=False,
            restricted=False,
            democracy=False,
            signatures=False,
            min=False,
            access_hash=4110269745224753542,
            username='dcxpblockchain',
            restriction_reason=None,
            admin_rights=None,
            banned_rights=None,
            participants_count=None
        ),
    ],
    users=[
    ]
)

Как получить доступ к полям? На сайте библиотеки не нашел примеров. Не вручную же разбирать.

Пытался так:

print(entity["full_chat"])

Выкидывает ошибку:

future: <Task finished coro=<get_entity() done, defined at D:/Git/telegram/telegram_new.py:53> exception=TypeError("'ChatFull' object is not subscriptable")>
Traceback (most recent call last):
  File "D:/Git/telegram/telegram_new.py", line 84, in get_entity
    await parse_entity(result)
  File "D:/Git/telegram/telegram_new.py", line 51, in parse_entity
    print(await entity["full_chat"])
TypeError: 'ChatFull' object is not subscriptable
3

1 ответ 1

0

Можно получить описание так:

print(entity.full_chat.id)

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.