diff --git a/compiler/docs/compiler.py b/compiler/docs/compiler.py index 5a75368d..82504063 100644 --- a/compiler/docs/compiler.py +++ b/compiler/docs/compiler.py @@ -459,6 +459,7 @@ def pyrogram_api(): stories=""" Stories Story + StoriesPrivacy StoryViews """, bot_keyboards=""" diff --git a/pyrogram/enums/__init__.py b/pyrogram/enums/__init__.py index d19c7044..042fded3 100644 --- a/pyrogram/enums/__init__.py +++ b/pyrogram/enums/__init__.py @@ -29,6 +29,7 @@ from .next_code_type import NextCodeType from .parse_mode import ParseMode from .poll_type import PollType from .sent_code_type import SentCodeType +from .stories_privacy import StoriesPrivacy from .user_status import UserStatus __all__ = [ @@ -44,6 +45,7 @@ __all__ = [ 'NextCodeType', 'ParseMode', 'PollType', - 'SentCodeType', + 'SentCodeType', + "StoriesPrivacy", 'UserStatus' ] diff --git a/pyrogram/enums/stories_privacy.py b/pyrogram/enums/stories_privacy.py new file mode 100644 index 00000000..ef7eb10f --- /dev/null +++ b/pyrogram/enums/stories_privacy.py @@ -0,0 +1,40 @@ +# Pyrofork - Telegram MTProto API Client Library for Python +# Copyright (C) 2022-present Mayuri-Chan +# +# This file is part of Pyrofork. +# +# Pyrofork is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pyrofork is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Pyrofork. If not, see . + +from enum import auto + +from .auto_name import AutoName + + +class StoriesPrivacy(AutoName): + """Poll type enumeration used in :obj:`~pyrogram.types.Stories`.""" + + PUBLIC = auto() + "Public stories" + + CLOSE_FRIENDS = auto() + "Close_Friends stories" + + CONTACTS = auto() + "Contacts only stories" + + PRIVATE = auto() + "Private stories" + + NO_CONTACTS = auto() + "Hide stories from contacts" diff --git a/pyrogram/types/messages_and_media/__init__.py b/pyrogram/types/messages_and_media/__init__.py index 0bc5b9cc..97be2472 100644 --- a/pyrogram/types/messages_and_media/__init__.py +++ b/pyrogram/types/messages_and_media/__init__.py @@ -31,6 +31,7 @@ from .poll_option import PollOption from .reaction import Reaction from .sticker import Sticker from .stickerset import StickerSet +from .stories_privacy import StoriesPrivacy from .stripped_thumbnail import StrippedThumbnail from .thumbnail import Thumbnail from .venue import Venue @@ -46,5 +47,5 @@ from .story_views import StoryViews __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", "Story", "StoryViews" + "Reaction", "WebAppData", "MessageReactions", "Story", "StoryViews", "StoriesPrivacy" ] diff --git a/pyrogram/types/messages_and_media/stories_privacy.py b/pyrogram/types/messages_and_media/stories_privacy.py new file mode 100644 index 00000000..1bfcb6ae --- /dev/null +++ b/pyrogram/types/messages_and_media/stories_privacy.py @@ -0,0 +1,47 @@ +# Pyrofork - Telegram MTProto API Client Library for Python +# Copyright (C) 2022-present Mayuri-Chan +# +# This file is part of Pyrofork. +# +# Pyrofork is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pyrofork is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Pyrofork. If not, see . + +from pyrogram import enums, raw +from ..object import Object + +class StoriesPrivacy(Object): + """A story privacy. + + Parameters: + type (:obj:`~pyrogram.enums.StoriesPrivary`): + Story privacy type. + """ + + def __init__( + self, *, + type: "enums.StoriesPrivacy" + ): + super().__init__() + self.type = type + + def write(self): + if self.type == enums.StoriesPrivacy.PUBLIC: + return raw.types.InputPrivacyValueAllowAll().write() + if self.type == enums.StoriesPrivacy.CLOSE_FRIENDS: + return raw.types.InputPrivacyValueAllowCloseFriends().write() + if self.type == enums.StoriesPrivacy.CONTACTS: + return raw.types.InputPrivacyValueAllowContacts().write() + if self.type == enums.StoriesPrivacy.NO_CONTACTS: + return raw.types.InputPrivacyValueDisallowContacts().write() + if self.type == enums.StoriesPrivacy.PRIVATE: + return raw.types.InputPrivacyValueDisallowAll().write()