diff --git a/pyrogram/methods/stories/edit_story_privacy.py b/pyrogram/methods/stories/edit_story_privacy.py index a57adc50a7..3e114a0b22 100644 --- a/pyrogram/methods/stories/edit_story_privacy.py +++ b/pyrogram/methods/stories/edit_story_privacy.py @@ -26,7 +26,7 @@ async def edit_story_privacy( self: "pyrogram.Client", chat_id: Union[int, str], story_id: int, - privacy: "enums.StoriesPrivacyRules" = None, + privacy: "enums.StoriesPrivacyRules" = enums.StoriesPrivacyRules.PUBLIC, allowed_users: List[Union[int, str]] = None, disallowed_users: List[Union[int, str]] = None, ) -> "types.Story": @@ -44,7 +44,7 @@ async def edit_story_privacy( Story identifier in the chat specified in chat_id. privacy (:obj:`~pyrogram.enums.StoriesPrivacyRules`, *optional*): - Story privacy. + Story privacy. Defaults to :obj:`~pyrogram.enums.StoriesPrivacyRules.PUBLIC`. allowed_users (List of ``int`` | ``str``, *optional*): List of user_id or chat_id of chat users who are allowed to view stories. @@ -76,39 +76,39 @@ async def edit_story_privacy( """ privacy_rules = [] - if privacy: - if privacy == enums.StoriesPrivacyRules.PUBLIC: - privacy_rules.append(raw.types.InputPrivacyValueAllowAll()) - if disallowed_users: - users = [await self.resolve_peer(user_id) for user_id in disallowed_users] - privacy_rules.append(raw.types.InputPrivacyValueDisallowUsers(users=users)) - elif privacy == enums.StoriesPrivacyRules.CONTACTS: - privacy_rules = [raw.types.InputPrivacyValueAllowContacts()] - if disallowed_users: - users = [await self.resolve_peer(user_id) for user_id in disallowed_users] - privacy_rules.append(raw.types.InputPrivacyValueDisallowUsers(users=users)) - elif privacy == enums.StoriesPrivacyRules.CLOSE_FRIENDS: - privacy_rules = [raw.types.InputPrivacyValueAllowCloseFriends()] - if allowed_users: - users = [await self.resolve_peer(user_id) for user_id in allowed_users] - privacy_rules.append(raw.types.InputPrivacyValueAllowUsers(users=users)) - elif privacy == enums.StoriesPrivacyRules.SELECTED_USERS: - _allowed_users = [] - _allowed_chats = [] - - for user in allowed_users: - peer = await self.resolve_peer(user) - if isinstance(peer, raw.types.InputPeerUser): - _allowed_users.append(peer) - elif isinstance(peer, (raw.types.InputPeerChat, raw.types.InputPeerChannel)): - _allowed_chats.append(peer) - - if _allowed_users: - privacy_rules.append(raw.types.InputPrivacyValueAllowUsers(users=_allowed_users)) - if _allowed_chats: - privacy_rules.append(raw.types.InputPrivacyValueAllowChatParticipants(chats=_allowed_chats)) - else: + if not privacy: + privacy = enums.StoriesPrivacyRules.PUBLIC + + if privacy == enums.StoriesPrivacyRules.PUBLIC: privacy_rules.append(raw.types.InputPrivacyValueAllowAll()) + if disallowed_users: + users = [await self.resolve_peer(user_id) for user_id in disallowed_users] + privacy_rules.append(raw.types.InputPrivacyValueDisallowUsers(users=users)) + elif privacy == enums.StoriesPrivacyRules.CONTACTS: + privacy_rules = [raw.types.InputPrivacyValueAllowContacts()] + if disallowed_users: + users = [await self.resolve_peer(user_id) for user_id in disallowed_users] + privacy_rules.append(raw.types.InputPrivacyValueDisallowUsers(users=users)) + elif privacy == enums.StoriesPrivacyRules.CLOSE_FRIENDS: + privacy_rules = [raw.types.InputPrivacyValueAllowCloseFriends()] + if allowed_users: + users = [await self.resolve_peer(user_id) for user_id in allowed_users] + privacy_rules.append(raw.types.InputPrivacyValueAllowUsers(users=users)) + elif privacy == enums.StoriesPrivacyRules.SELECTED_USERS: + _allowed_users = [] + _allowed_chats = [] + + for user in allowed_users: + peer = await self.resolve_peer(user) + if isinstance(peer, raw.types.InputPeerUser): + _allowed_users.append(peer) + elif isinstance(peer, (raw.types.InputPeerChat, raw.types.InputPeerChannel)): + _allowed_chats.append(peer) + + if _allowed_users: + privacy_rules.append(raw.types.InputPrivacyValueAllowUsers(users=_allowed_users)) + if _allowed_chats: + privacy_rules.append(raw.types.InputPrivacyValueAllowChatParticipants(chats=_allowed_chats)) r = await self.invoke( diff --git a/pyrogram/types/messages_and_media/story.py b/pyrogram/types/messages_and_media/story.py index 04402bf04a..e6f9e9b4f9 100644 --- a/pyrogram/types/messages_and_media/story.py +++ b/pyrogram/types/messages_and_media/story.py @@ -104,7 +104,7 @@ class Story(Object, Update): forwards (``int``, *optional*): Stories forwards. - privacy (:obj:`~pyrogram.enums.StoryPrivacyRules`, *optional*): + privacy (:obj:`~pyrogram.enums.StoriesPrivacyRules`, *optional*): Story privacy. allowed_users (List of ``int`` | ``str``, *optional*): @@ -158,7 +158,7 @@ def __init__( caption_entities: List["types.MessageEntity"] = None, views: int = None, forwards: int = None, - privacy: "enums.StoryPrivacyRules" = None, + privacy: "enums.StoriesPrivacyRules" = None, allowed_users: List[Union[int, str]] = None, disallowed_users: List[Union[int, str]] = None, reactions: List["types.Reaction"] = None, @@ -1605,7 +1605,7 @@ async def edit_caption( async def edit_privacy( self, - privacy: "enums.StoriesPrivacyRules" = None, + privacy: "enums.StoriesPrivacyRules" = enums.StoriesPrivacyRules.PUBLIC, allowed_users: List[Union[int, str]] = None, disallowed_users: List[Union[int, str]] = None, ) -> "types.Story": @@ -1627,7 +1627,7 @@ async def edit_privacy( Parameters: privacy (:obj:`~pyrogram.enums.StoriesPrivacyRules`, *optional*): - Story privacy. + Story privacy. Defaults to :obj:`~pyrogram.enums.StoriesPrivacyRules.PUBLIC`. allowed_users (List of ``int`` | ``str``, *optional*): List of user_id or chat_id of chat users who are allowed to view stories.