Pyrofork: Add StoriesPrivacy

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2023-08-13 21:04:51 +07:00
parent 983d39c092
commit acd70f7f2e
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
5 changed files with 93 additions and 2 deletions

View file

@ -459,6 +459,7 @@ def pyrogram_api():
stories="""
Stories
Story
StoriesPrivacy
StoryViews
""",
bot_keyboards="""

View file

@ -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'
]

View file

@ -0,0 +1,40 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/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 <http://www.gnu.org/licenses/>.
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"

View file

@ -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"
]

View file

@ -0,0 +1,47 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/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 <http://www.gnu.org/licenses/>.
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()