Skip to content

[QUESTION] Append/Update on ChatPermissions #1834

@AyraHikari

Description

@AyraHikari

Issue I am facing

I am facing issue when trying to set permission for send poll to True
chat.set_permissions(permission=ChatPermissions(can_send_polls=True))
Then send media, send stickers and gifs, and embed links are turned off.
Because it should not, so i am going to check current permission and replace to new permission and set new one.
And now i am stuck at ChatPermission, since it wasn't dict. So i can't merge or append at ChatPermission.

Traceback to the issue

chat.set_permissions(permission=ChatPermissions(can_send_polls=True))

changed default permissions

+Send polls
−Send media
−Send stickers & GIFs
−Embed links

Related part of your code

current = context.bot.getChat(chat_id).permissions
new = {'can_send_polls': True}

permissions = {'can_send_messages': None, 'can_send_media_messages': None, 'can_send_polls': None, 'can_send_other_messages': None, 'can_add_web_page_previews': None, 'can_change_info': None, 'can_invite_users': None, 'can_pin_messages': None}
permissions.update(current)
permissions.update(new)
# ???

doing chat.set_permissions(permission=permissions) will got error since set_permissions is converting to_dict() at

data = {'chat_id': chat_id, 'permissions': permissions.to_dict()}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions