Skip to content

Commit

Permalink
Pyrofork: Rename StoriesPrivacy to StoriesPrivacyRules
Browse files Browse the repository at this point in the history
Signed-off-by: wulan17 <wulan17@nusantararom.org>
  • Loading branch information
wulan17 committed Oct 5, 2023
1 parent cc6f7f6 commit 4e5be20
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions docs/source/api/enums/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ to apply only a valid value among the expected ones.
SentCodeType
NextCodeType
UserStatus
StoriesPrivacy
StoriesPrivacyRules

.. toctree::
:hidden:
Expand All @@ -46,4 +46,4 @@ to apply only a valid value among the expected ones.
SentCodeType
NextCodeType
UserStatus
StoriesPrivacy
StoriesPrivacyRules
4 changes: 2 additions & 2 deletions pyrogram/enums/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from .parse_mode import ParseMode
from .poll_type import PollType
from .sent_code_type import SentCodeType
from .stories_privacy import StoriesPrivacy
from .stories_privacy_rules import StoriesPrivacyRules
from .user_status import UserStatus

__all__ = [
Expand All @@ -46,6 +46,6 @@
'ParseMode',
'PollType',
'SentCodeType',
"StoriesPrivacy",
"StoriesPrivacyRules",
'UserStatus'
]
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from .auto_name import AutoName


class StoriesPrivacy(AutoName):
class StoriesPrivacyRules(AutoName):
"""Poll type enumeration used in :obj:`~pyrogram.types.Story`."""

PUBLIC = auto()
Expand Down
6 changes: 3 additions & 3 deletions pyrogram/methods/users/edit_story.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async def edit_story(
self: "pyrogram.Client",
story_id: int,
channel_id: int = None,
privacy: "enums.StoriesPrivacy" = None,
privacy: "enums.StoriesPrivacyRules" = None,
allowed_users: List[int] = None,
denied_users: List[int] = None,
allowed_chats: List[int] = None,
Expand Down Expand Up @@ -76,7 +76,7 @@ async def edit_story(
pass a file path as string to upload a new video that exists on your local machine, or
pass a binary file-like object with its attribute ".name" set for in-memory uploads.
privacy (:obj:`~pyrogram.enums.StoriesPrivacy`, *optional*):
privacy (:obj:`~pyrogram.enums.StoriesPrivacyRules`, *optional*):
Story privacy.
allowed_chats (List of ``int``, *optional*):
Expand Down Expand Up @@ -126,7 +126,7 @@ async def edit_story(
privacy_rules = None

if privacy:
privacy_rules = [types.StoriesPrivacy(type=privacy)]
privacy_rules = [types.StoriesPrivacyRules(type=privacy)]

if animation:
if isinstance(animation, str):
Expand Down
10 changes: 5 additions & 5 deletions pyrogram/methods/users/send_story.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _split(self, message, entities, *args, **kwargs):
async def send_story(
self: "pyrogram.Client",
channel_id: int = None,
privacy: "enums.StoriesPrivacy" = None,
privacy: "enums.StoriesPrivacyRules" = None,
allowed_users: List[int] = None,
denied_users: List[int] = None,
allowed_chats: List[int] = None,
Expand Down Expand Up @@ -77,9 +77,9 @@ async def send_story(
pass a file path as string to upload a new video that exists on your local machine, or
pass a binary file-like object with its attribute ".name" set for in-memory uploads.
privacy (:obj:`~pyrogram.enums.StoriesPrivacy`, *optional*):
privacy (:obj:`~pyrogram.enums.StoriesPrivacyRules`, *optional*):
Story privacy.
Defaults to :obj:`~pyrogram.enums.StoriesPrivacy.PUBLIC`
Defaults to :obj:`~pyrogram.enums.StoriesPrivacyRules.PUBLIC`
allowed_chats (List of ``int``, *optional*):
List of chat_id which participant allowed to view the story.
Expand Down Expand Up @@ -136,9 +136,9 @@ async def send_story(
peer = await self.resolve_peer("me")

if privacy:
privacy_rules = [types.StoriesPrivacy(type=privacy)]
privacy_rules = [types.StoriesPrivacyRules(type=privacy)]
else:
privacy_rules = [types.StoriesPrivacy(type=enums.StoriesPrivacy.PUBLIC)]
privacy_rules = [types.StoriesPrivacyRules(type=enums.StoriesPrivacyRules.PUBLIC)]

if animation:
if isinstance(animation, str):
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/types/messages_and_media/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from .reaction import Reaction
from .sticker import Sticker
from .stickerset import StickerSet
from .stories_privacy import StoriesPrivacy
from .stories_privacy_rules import StoriesPrivacyRules
from .stripped_thumbnail import StrippedThumbnail
from .thumbnail import Thumbnail
from .venue import Venue
Expand All @@ -51,5 +51,5 @@
__all__ = [
"Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Photo", "Thumbnail",
"StrippedThumbnail", "Poll", "PollOption", "Sticker", "StickerSet", "Venue", "Video", "VideoNote", "Voice", "WebPage", "Dice",
"Reaction", "WebAppData", "MessageReactions", "MessageStory", "Story", "StoryDeleted", "StorySkipped", "StoryViews", "StoriesPrivacy", "ExportedStoryLink"
"Reaction", "WebAppData", "MessageReactions", "MessageStory", "Story", "StoryDeleted", "StorySkipped", "StoryViews", "StoriesPrivacyRules", "ExportedStoryLink"
]
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,29 @@
from pyrogram import enums, raw
from ..object import Object

class StoriesPrivacy(Object):
class StoriesPrivacyRules(Object):
"""A story privacy.
Parameters:
type (:obj:`~pyrogram.enums.StoriesPrivacy`):
type (:obj:`~pyrogram.enums.StoriesPrivacyRules`):
Story privacy type.
"""

def __init__(
self, *,
type: "enums.StoriesPrivacy"
type: "enums.StoriesPrivacyRules"
):
super().__init__()
self.type = type

def write(self):
if self.type == enums.StoriesPrivacy.PUBLIC:
if self.type == enums.StoriesPrivacyRules.PUBLIC:
return raw.types.InputPrivacyValueAllowAll().write()
if self.type == enums.StoriesPrivacy.CLOSE_FRIENDS:
if self.type == enums.StoriesPrivacyRules.CLOSE_FRIENDS:
return raw.types.InputPrivacyValueAllowCloseFriends().write()
if self.type == enums.StoriesPrivacy.CONTACTS:
if self.type == enums.StoriesPrivacyRules.CONTACTS:
return raw.types.InputPrivacyValueAllowContacts().write()
if self.type == enums.StoriesPrivacy.NO_CONTACTS:
if self.type == enums.StoriesPrivacyRules.NO_CONTACTS:
return raw.types.InputPrivacyValueDisallowContacts().write()
if self.type == enums.StoriesPrivacy.PRIVATE:
if self.type == enums.StoriesPrivacyRules.PRIVATE:
return raw.types.InputPrivacyValueDisallowAll().write()
12 changes: 6 additions & 6 deletions pyrogram/types/messages_and_media/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ async def edit_animation(

async def edit(
self,
privacy: "enums.StoriesPrivacy" = None,
privacy: "enums.StoriesPrivacyRules" = None,
allowed_users: List[int] = None,
denied_users: List[int] = None,
allowed_chats: List[int] = None,
Expand Down Expand Up @@ -1418,7 +1418,7 @@ async def edit(
channel=self.sender_chat.id if self.sender_chat else None,new video that exists on your local machine, or
pass a binary file-like object with its attribute ".name" set for in-memory uploads.
privacy (:obj:`~pyrogram.enums.StoriesPrivacy`, *optional*):
privacy (:obj:`~pyrogram.enums.StoriesPrivacyRules`, *optional*):
Story privacy.
allowed_chats (List of ``int``, *optional*):
Expand Down Expand Up @@ -1548,7 +1548,7 @@ async def edit_photo(

async def edit_privacy(
self,
privacy: "enums.StoriesPrivacy" = None,
privacy: "enums.StoriesPrivacyRules" = None,
allowed_users: List[int] = None,
denied_users: List[int] = None,
allowed_chats: List[int] = None,
Expand All @@ -1562,16 +1562,16 @@ async def edit_privacy(
await client.edit_story(
story_id=story.id,
privacy=enums.StoriesPrivacy.PUBLIC
privacy=enums.StoriesPrivacyRules.PUBLIC
)
Example:
.. code-block:: python
await story.edit_privacy(enums.StoriesPrivacy.PUBLIC)
await story.edit_privacy(enums.StoriesPrivacyRules.PUBLIC)
Parameters:
privacy (:obj:`~pyrogram.enums.StoriesPrivacy`, *optional*):
privacy (:obj:`~pyrogram.enums.StoriesPrivacyRules`, *optional*):
Story privacy.
allowed_chats (List of ``int``, *optional*):
Expand Down

0 comments on commit 4e5be20

Please sign in to comment.