Source code for pyrogram.raw.types.global_privacy_settings

#  Pyrogram - Telegram MTProto API Client Library for Python
#  Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
#  This file is part of Pyrogram.
#
#  Pyrogram 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.
#
#  Pyrogram 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 Pyrogram.  If not, see <http://www.gnu.org/licenses/>.

from io import BytesIO

from pyrogram.raw.core.primitives import Int, Long, Int128, Int256, Bool, Bytes, String, Double, Vector
from pyrogram.raw.core import TLObject
from pyrogram import raw
from typing import List, Optional, Any

# # # # # # # # # # # # # # # # # # # # # # # #
#               !!! WARNING !!!               #
#          This is a generated file!          #
# All changes made in this file will be lost! #
# # # # # # # # # # # # # # # # # # # # # # # #


[docs] class GlobalPrivacySettings(TLObject): # type: ignore """Global privacy settings Constructor of :obj:`~pyrogram.raw.base.GlobalPrivacySettings`. Details: - Layer: ``229`` - ID: ``FE41B34F`` Parameters: archive_and_mute_new_noncontact_peers (``bool``, *optional*): Whether to archive and mute new chats from non-contacts keep_archived_unmuted (``bool``, *optional*): Whether unmuted chats will be kept in the Archive chat list when they get a new message. keep_archived_folders (``bool``, *optional*): Whether unmuted chats that are always included or pinned in a `folder <https://core.telegram.org/api/folders>`_, will be kept in the Archive chat list when they get a new message. Ignored if ``keep_archived_unmuted`` is set. hide_read_marks (``bool``, *optional*): If this flag is set, the `inputPrivacyKeyStatusTimestamp <https://core.telegram.org/constructor/inputPrivacyKeyStatusTimestamp>`_ key will also apply to the ability to use `messages.getOutboxReadDate <https://core.telegram.org/method/messages.getOutboxReadDate>`_ on messages sent to us. Meaning, users that cannot see *our* exact last online date due to the current value of the `inputPrivacyKeyStatusTimestamp <https://core.telegram.org/constructor/inputPrivacyKeyStatusTimestamp>`_ key will receive a ``403 USER_PRIVACY_RESTRICTED`` error when invoking `messages.getOutboxReadDate <https://core.telegram.org/method/messages.getOutboxReadDate>`_ to fetch the exact read date of a message they sent to us. The `userFull <https://core.telegram.org/constructor/userFull>`_. ``read_dates_private`` flag will be set for users that have this flag enabled. new_noncontact_peers_require_premium (``bool``, *optional*): See `here for more info on this flag » <https://core.telegram.org/api/privacy#require-premium-for-new-non-contact-users>`_. display_gifts_button (``bool``, *optional*): Enables or disables our `userFull <https://core.telegram.org/constructor/userFull>`_. ``display_gifts_button`` flag: if the `userFull <https://core.telegram.org/constructor/userFull>`_. ``display_gifts_button`` flag of both us and another user is set, a gift button should always be displayed in the text field in private chats with the other user: once clicked, the gift UI should be displayed, offering the user options to gift `Telegram Premium » <https://core.telegram.org/api/premium#gifting-telegram-premium>`_ subscriptions or `Telegram Gifts » <https://core.telegram.org/api/gifts>`_. noncontact_peers_paid_stars (``int`` ``64-bit``, *optional*): If configured, specifies the number of `stars <https://core.telegram.org/api/stars>`_ users must pay us to send us a message, see `here » <https://core.telegram.org/api/paid-messages>`_ for more info on paid messages. disallowed_gifts (:obj:`DisallowedGiftsSettings <pyrogram.raw.base.DisallowedGiftsSettings>`, *optional*): Disallows the reception of specific gift types. Functions: This object can be returned by 2 functions. .. currentmodule:: pyrogram.raw.functions .. autosummary:: :nosignatures: account.GetGlobalPrivacySettings account.SetGlobalPrivacySettings """ __slots__: List[str] = ["archive_and_mute_new_noncontact_peers", "keep_archived_unmuted", "keep_archived_folders", "hide_read_marks", "new_noncontact_peers_require_premium", "display_gifts_button", "noncontact_peers_paid_stars", "disallowed_gifts"] ID = 0xfe41b34f QUALNAME = "types.GlobalPrivacySettings" def __init__(self, *, archive_and_mute_new_noncontact_peers: Optional[bool] = None, keep_archived_unmuted: Optional[bool] = None, keep_archived_folders: Optional[bool] = None, hide_read_marks: Optional[bool] = None, new_noncontact_peers_require_premium: Optional[bool] = None, display_gifts_button: Optional[bool] = None, noncontact_peers_paid_stars: Optional[int] = None, disallowed_gifts: "raw.base.DisallowedGiftsSettings" = None) -> None: self.archive_and_mute_new_noncontact_peers = archive_and_mute_new_noncontact_peers # flags.0?true self.keep_archived_unmuted = keep_archived_unmuted # flags.1?true self.keep_archived_folders = keep_archived_folders # flags.2?true self.hide_read_marks = hide_read_marks # flags.3?true self.new_noncontact_peers_require_premium = new_noncontact_peers_require_premium # flags.4?true self.display_gifts_button = display_gifts_button # flags.7?true self.noncontact_peers_paid_stars = noncontact_peers_paid_stars # flags.5?long self.disallowed_gifts = disallowed_gifts # flags.6?DisallowedGiftsSettings @staticmethod def read(b: BytesIO, *args: Any) -> "GlobalPrivacySettings": flags = Int.read(b) archive_and_mute_new_noncontact_peers = True if flags & (1 << 0) else False keep_archived_unmuted = True if flags & (1 << 1) else False keep_archived_folders = True if flags & (1 << 2) else False hide_read_marks = True if flags & (1 << 3) else False new_noncontact_peers_require_premium = True if flags & (1 << 4) else False display_gifts_button = True if flags & (1 << 7) else False noncontact_peers_paid_stars = Long.read(b) if flags & (1 << 5) else None disallowed_gifts = TLObject.read(b) if flags & (1 << 6) else None return GlobalPrivacySettings(archive_and_mute_new_noncontact_peers=archive_and_mute_new_noncontact_peers, keep_archived_unmuted=keep_archived_unmuted, keep_archived_folders=keep_archived_folders, hide_read_marks=hide_read_marks, new_noncontact_peers_require_premium=new_noncontact_peers_require_premium, display_gifts_button=display_gifts_button, noncontact_peers_paid_stars=noncontact_peers_paid_stars, disallowed_gifts=disallowed_gifts) def write(self, *args) -> bytes: b = BytesIO() b.write(Int(self.ID, False)) flags = 0 flags |= (1 << 0) if self.archive_and_mute_new_noncontact_peers else 0 flags |= (1 << 1) if self.keep_archived_unmuted else 0 flags |= (1 << 2) if self.keep_archived_folders else 0 flags |= (1 << 3) if self.hide_read_marks else 0 flags |= (1 << 4) if self.new_noncontact_peers_require_premium else 0 flags |= (1 << 7) if self.display_gifts_button else 0 flags |= (1 << 5) if self.noncontact_peers_paid_stars is not None else 0 flags |= (1 << 6) if self.disallowed_gifts is not None else 0 b.write(Int(flags)) if self.noncontact_peers_paid_stars is not None: b.write(Long(self.noncontact_peers_paid_stars)) if self.disallowed_gifts is not None: b.write(self.disallowed_gifts.write()) return b.getvalue()