Pyrofork: Stories: Disable allowed_chats privacy for now

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2023-10-05 20:10:02 +07:00
parent 8036da6e32
commit da9c45a987
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
3 changed files with 36 additions and 61 deletions

View file

@ -35,8 +35,8 @@ class EditStory:
privacy: "enums.StoriesPrivacyRules" = None, privacy: "enums.StoriesPrivacyRules" = None,
allowed_users: List[int] = None, allowed_users: List[int] = None,
denied_users: List[int] = None, denied_users: List[int] = None,
allowed_chats: List[int] = None, #allowed_chats: List[int] = None,
denied_chats: List[int] = None, #denied_chats: List[int] = None,
animation: str = None, animation: str = None,
photo: str = None, photo: str = None,
video: str = None, video: str = None,
@ -79,12 +79,6 @@ class EditStory:
privacy (:obj:`~pyrogram.enums.StoriesPrivacyRules`, *optional*): privacy (:obj:`~pyrogram.enums.StoriesPrivacyRules`, *optional*):
Story privacy. Story privacy.
allowed_chats (List of ``int``, *optional*):
List of chat_id which participant allowed to view the story.
denied_chats (List of ``int``, *optional*):
List of chat_id which participant denied to view the story.
allowed_users (List of ``int``, *optional*): allowed_users (List of ``int``, *optional*):
List of user_id whos allowed to view the story. List of user_id whos allowed to view the story.
@ -225,12 +219,14 @@ class EditStory:
if caption: if caption:
text, entities = self._split(**await utils.parse_text_entities(self, caption, parse_mode, caption_entities)) text, entities = self._split(**await utils.parse_text_entities(self, caption, parse_mode, caption_entities))
'''
if allowed_chats and len(allowed_chats) > 0: if allowed_chats and len(allowed_chats) > 0:
chats = [await self.resolve_peer(chat_id) for chat_id in allowed_chats] chats = [int(str(chat_id)[3:]) if str(chat_id).startswith("-100") else chat_id for chat_id in allowed_chats]
privacy_rules.append(raw.types.InputPrivacyValueAllowChatParticipants(chats=chats)) privacy_rules.append(raw.types.InputPrivacyValueAllowChatParticipants(chats=chats))
if denied_chats and len(denied_chats) > 0: if denied_chats and len(denied_chats) > 0:
chats = [await self.resolve_peer(chat_id) for chat_id in denied_chats] chats = [int(str(chat_id)[3:]) if str(chat_id).startswith("-100") else chat_id for chat_id in denied_chats]
privacy_rules.append(raw.types.InputPrivacyValueDisallowChatParticipants(chats=chats)) privacy_rules.append(raw.types.InputPrivacyValueDisallowChatParticipants(chats=chats))
'''
if allowed_users and len(allowed_users) > 0: if allowed_users and len(allowed_users) > 0:
users = [await self.resolve_peer(user_id) for user_id in allowed_users] users = [await self.resolve_peer(user_id) for user_id in allowed_users]
privacy_rules.append(raw.types.InputPrivacyValueAllowUsers(users=users)) privacy_rules.append(raw.types.InputPrivacyValueAllowUsers(users=users))

View file

@ -34,8 +34,8 @@ class SendStory:
privacy: "enums.StoriesPrivacyRules" = None, privacy: "enums.StoriesPrivacyRules" = None,
allowed_users: List[int] = None, allowed_users: List[int] = None,
denied_users: List[int] = None, denied_users: List[int] = None,
allowed_chats: List[int] = None, #allowed_chats: List[int] = None,
denied_chats: List[int] = None, #denied_chats: List[int] = None,
animation: str = None, animation: str = None,
photo: str = None, photo: str = None,
video: str = None, video: str = None,
@ -81,12 +81,6 @@ class SendStory:
Story privacy. Story privacy.
Defaults to :obj:`~pyrogram.enums.StoriesPrivacyRules.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.
denied_chats (List of ``int``, *optional*):
List of chat_id which participant denied to view the story.
allowed_users (List of ``int``, *optional*): allowed_users (List of ``int``, *optional*):
List of user_id whos allowed to view the story. List of user_id whos allowed to view the story.
@ -237,12 +231,14 @@ class SendStory:
text, entities = self._split(**await utils.parse_text_entities(self, caption, parse_mode, caption_entities)) text, entities = self._split(**await utils.parse_text_entities(self, caption, parse_mode, caption_entities))
'''
if allowed_chats and len(allowed_chats) > 0: if allowed_chats and len(allowed_chats) > 0:
chats = [await self.resolve_peer(chat_id) for chat_id in allowed_chats] chats = [await self.resolve_peer(chat_id) for chat_id in allowed_chats]
privacy_rules.append(raw.types.InputPrivacyValueAllowChatParticipants(chats=chats)) privacy_rules.append(raw.types.InputPrivacyValueAllowChatParticipants(chats=chats))
if denied_chats and len(denied_chats) > 0: if denied_chats and len(denied_chats) > 0:
chats = [await self.resolve_peer(chat_id) for chat_id in denied_chats] chats = [await self.resolve_peer(chat_id) for chat_id in denied_chats]
privacy_rules.append(raw.types.InputPrivacyValueDisallowChatParticipants(chats=chats)) privacy_rules.append(raw.types.InputPrivacyValueDisallowChatParticipants(chats=chats))
'''
if allowed_users and len(allowed_users) > 0: if allowed_users and len(allowed_users) > 0:
users = [await self.resolve_peer(user_id) for user_id in allowed_users] users = [await self.resolve_peer(user_id) for user_id in allowed_users]
privacy_rules.append(raw.types.InputPrivacyValueAllowUsers(users=users)) privacy_rules.append(raw.types.InputPrivacyValueAllowUsers(users=users))

View file

@ -90,12 +90,6 @@ class Story(Object, Update):
privacy (:obj:`~pyrogram.enums.StoryPrivacy`, *optional*): privacy (:obj:`~pyrogram.enums.StoryPrivacy`, *optional*):
Story privacy. Story privacy.
allowed_chats (List of ``int``, *optional*):
List of chat_id which participant allowed to view the story.
denied_chats (List of ``int``, *optional*):
List of chat_id which participant denied to view the story.
allowed_users (List of ``int``, *optional*): allowed_users (List of ``int``, *optional*):
List of user_id whos allowed to view the story. List of user_id whos allowed to view the story.
@ -103,7 +97,7 @@ class Story(Object, Update):
List of user_id whos denied to view the story. List of user_id whos denied to view the story.
""" """
# TODO: Add Media Areas # TODO: Add Media Areas, fix Allowed Chats
def __init__( def __init__(
self, self,
@ -131,8 +125,8 @@ class Story(Object, Update):
privacy: "enums.StoryPrivacy" = None, privacy: "enums.StoryPrivacy" = None,
allowed_users: List[int] = None, allowed_users: List[int] = None,
denied_users: List[int] = None, denied_users: List[int] = None,
allowed_chats: List[int] = None, #allowed_chats: List[int] = None,
denied_chats: List[int] = None #denied_chats: List[int] = None
): ):
super().__init__(client) super().__init__(client)
@ -158,8 +152,8 @@ class Story(Object, Update):
self.privay = privacy self.privay = privacy
self.allowed_users = allowed_users self.allowed_users = allowed_users
self.denied_users = denied_users self.denied_users = denied_users
self.allowed_chats = allowed_chats #self.allowed_chats = allowed_chats
self.denied_chats = denied_chats #self.denied_chats = denied_chats
@staticmethod @staticmethod
async def _parse( async def _parse(
@ -179,9 +173,9 @@ class Story(Object, Update):
from_user = None from_user = None
sender_chat = None sender_chat = None
privacy = None privacy = None
allowed_chats = None #allowed_chats = None
allowed_users = None allowed_users = None
denied_chats = None #denied_chats = None
denied_users = None denied_users = None
if stories.media: if stories.media:
if isinstance(stories.media, raw.types.MessageMediaPhoto): if isinstance(stories.media, raw.types.MessageMediaPhoto):
@ -223,14 +217,15 @@ class Story(Object, Update):
privacy = enums.StoryPrivacy.PRIVATE privacy = enums.StoryPrivacy.PRIVATE
elif isinstance(priv, raw.types.PrivacyValueDisallowContacts): elif isinstance(priv, raw.types.PrivacyValueDisallowContacts):
privacy = enums.StoryPrivacy.NO_CONTACTS privacy = enums.StoryPrivacy.NO_CONTACTS
if isinstance(priv, raw.types.PrivacyValueAllowChatParticipants):
allowed_chats = [] '''
for chat in priv.chats: if allowed_chats and len(allowed_chats) > 0:
allowed_chats.append(f"-100{chat}") chats = [int(str(chat_id)[3:]) if str(chat_id).startswith("-100") else chat_id for chat_id in allowed_chats]
if isinstance(priv, raw.types.PrivacyValueDisallowChatParticipants): privacy_rules.append(raw.types.InputPrivacyValueAllowChatParticipants(chats=chats))
denied_chats = [] if denied_chats and len(denied_chats) > 0:
for chat in priv.chats: chats = [int(str(chat_id)[3:]) if str(chat_id).startswith("-100") else chat_id for chat_id in denied_chats]
denied_chats.append(f"-100{chat}") privacy_rules.append(raw.types.InputPrivacyValueDisallowChatParticipants(chats=chats))
'''
if isinstance(priv, raw.types.PrivacyValueAllowUsers): if isinstance(priv, raw.types.PrivacyValueAllowUsers):
allowed_users = priv.users allowed_users = priv.users
if isinstance(priv, raw.types.PrivacyValueDisallowUsers): if isinstance(priv, raw.types.PrivacyValueDisallowUsers):
@ -257,8 +252,8 @@ class Story(Object, Update):
caption_entities=entities or None, caption_entities=entities or None,
views=types.StoryViews._parse(stories.views), views=types.StoryViews._parse(stories.views),
privacy=privacy, privacy=privacy,
allowed_chats=allowed_chats, #allowed_chats=allowed_chats,
denied_chats=denied_chats, #denied_chats=denied_chats,
allowed_users=allowed_users, allowed_users=allowed_users,
denied_users=denied_users, denied_users=denied_users,
client=client client=client
@ -1426,8 +1421,8 @@ class Story(Object, Update):
privacy: "enums.StoriesPrivacyRules" = None, privacy: "enums.StoriesPrivacyRules" = None,
allowed_users: List[int] = None, allowed_users: List[int] = None,
denied_users: List[int] = None, denied_users: List[int] = None,
allowed_chats: List[int] = None, #allowed_chats: List[int] = None,
denied_chats: List[int] = None, #denied_chats: List[int] = None,
animation: str = None, animation: str = None,
photo: str = None, photo: str = None,
video: str = None, video: str = None,
@ -1480,12 +1475,6 @@ class Story(Object, Update):
privacy (:obj:`~pyrogram.enums.StoriesPrivacyRules`, *optional*): privacy (:obj:`~pyrogram.enums.StoriesPrivacyRules`, *optional*):
Story privacy. Story privacy.
allowed_chats (List of ``int``, *optional*):
List of chat_id which participant allowed to view the story.
denied_chats (List of ``int``, *optional*):
List of chat_id which participant denied to view the story.
allowed_users (List of ``int``, *optional*): allowed_users (List of ``int``, *optional*):
List of user_id whos allowed to view the story. List of user_id whos allowed to view the story.
@ -1512,8 +1501,8 @@ class Story(Object, Update):
channel_id=self.sender_chat.id if self.sender_chat else None, channel_id=self.sender_chat.id if self.sender_chat else None,
story_id=self.id, story_id=self.id,
privacy=privacy, privacy=privacy,
allowed_chats=allowed_chats, #allowed_chats=allowed_chats,
denied_chats=denied_chats, #denied_chats=denied_chats,
allowed_users=allowed_users, allowed_users=allowed_users,
denied_users=denied_users, denied_users=denied_users,
animation=animation, animation=animation,
@ -1610,8 +1599,8 @@ class Story(Object, Update):
privacy: "enums.StoriesPrivacyRules" = None, privacy: "enums.StoriesPrivacyRules" = None,
allowed_users: List[int] = None, allowed_users: List[int] = None,
denied_users: List[int] = None, denied_users: List[int] = None,
allowed_chats: List[int] = None, #allowed_chats: List[int] = None,
denied_chats: List[int] = None #denied_chats: List[int] = None
) -> "types.Story": ) -> "types.Story":
"""Bound method *edit_privacy* of :obj:`~pyrogram.types.Story`. """Bound method *edit_privacy* of :obj:`~pyrogram.types.Story`.
@ -1633,12 +1622,6 @@ class Story(Object, Update):
privacy (:obj:`~pyrogram.enums.StoriesPrivacyRules`, *optional*): privacy (:obj:`~pyrogram.enums.StoriesPrivacyRules`, *optional*):
Story privacy. Story privacy.
allowed_chats (List of ``int``, *optional*):
List of chat_id which participant allowed to view the story.
denied_chats (List of ``int``, *optional*):
List of chat_id which participant denied to view the story.
allowed_users (List of ``int``, *optional*): allowed_users (List of ``int``, *optional*):
List of user_id whos allowed to view the story. List of user_id whos allowed to view the story.
@ -1655,8 +1638,8 @@ class Story(Object, Update):
channel_id=self.sender_chat.id if self.sender_chat else None, channel_id=self.sender_chat.id if self.sender_chat else None,
story_id=self.id, story_id=self.id,
privacy=privacy, privacy=privacy,
allowed_chats=allowed_chats, #allowed_chats=allowed_chats,
denied_chats=denied_chats, #denied_chats=denied_chats,
allowed_users=allowed_users, allowed_users=allowed_users,
denied_users=denied_users denied_users=denied_users
) )