Source code for pyrogram.raw.types.dialog

#  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 Dialog(TLObject): # type: ignore """Chat Constructor of :obj:`~pyrogram.raw.base.Dialog`. Details: - Layer: ``229`` - ID: ``FC89F7F3`` Parameters: peer (:obj:`Peer <pyrogram.raw.base.Peer>`): The chat top_message (``int`` ``32-bit``): The latest message ID read_inbox_max_id (``int`` ``32-bit``): Position up to which all incoming messages are read. read_outbox_max_id (``int`` ``32-bit``): Position up to which all outgoing messages are read. unread_count (``int`` ``32-bit``): Number of unread messages unread_mentions_count (``int`` ``32-bit``): Number of `unread mentions <https://core.telegram.org/api/mentions>`_ unread_reactions_count (``int`` ``32-bit``): Number of unread reactions to messages you sent unread_poll_votes_count (``int`` ``32-bit``): Number of `unread votes cast in non-anonymous polls ยป <https://core.telegram.org/api/poll#unread-poll-votes>`_ owned by the user in this dialog. notify_settings (:obj:`PeerNotifySettings <pyrogram.raw.base.PeerNotifySettings>`): Notification settings pinned (``bool``, *optional*): Is the dialog pinned unread_mark (``bool``, *optional*): Whether the chat was manually marked as unread view_forum_as_messages (``bool``, *optional*): Users may also choose to display messages from all topics of a `forum <https://core.telegram.org/api/forum>`_ as if they were sent to a normal group, using a "View as messages" setting in the local client. This setting only affects the current account, and is synced to other logged in sessions using the `channels.toggleViewForumAsMessages <https://core.telegram.org/method/channels.toggleViewForumAsMessages>`_ method; invoking this method will update the value of this flag. pts (``int`` ``32-bit``, *optional*): `PTS <https://core.telegram.org/api/updates>`_ draft (:obj:`DraftMessage <pyrogram.raw.base.DraftMessage>`, *optional*): Message `draft <https://core.telegram.org/api/drafts>`_ folder_id (``int`` ``32-bit``, *optional*): `Peer folder ID, for more info click here <https://core.telegram.org/api/folders#peer-folders>`_ ttl_period (``int`` ``32-bit``, *optional*): Time-to-live of all messages sent in this dialog """ __slots__: List[str] = ["peer", "top_message", "read_inbox_max_id", "read_outbox_max_id", "unread_count", "unread_mentions_count", "unread_reactions_count", "unread_poll_votes_count", "notify_settings", "pinned", "unread_mark", "view_forum_as_messages", "pts", "draft", "folder_id", "ttl_period"] ID = 0xfc89f7f3 QUALNAME = "types.Dialog" def __init__(self, *, peer: "raw.base.Peer", top_message: int, read_inbox_max_id: int, read_outbox_max_id: int, unread_count: int, unread_mentions_count: int, unread_reactions_count: int, unread_poll_votes_count: int, notify_settings: "raw.base.PeerNotifySettings", pinned: Optional[bool] = None, unread_mark: Optional[bool] = None, view_forum_as_messages: Optional[bool] = None, pts: Optional[int] = None, draft: "raw.base.DraftMessage" = None, folder_id: Optional[int] = None, ttl_period: Optional[int] = None) -> None: self.peer = peer # Peer self.top_message = top_message # int self.read_inbox_max_id = read_inbox_max_id # int self.read_outbox_max_id = read_outbox_max_id # int self.unread_count = unread_count # int self.unread_mentions_count = unread_mentions_count # int self.unread_reactions_count = unread_reactions_count # int self.unread_poll_votes_count = unread_poll_votes_count # int self.notify_settings = notify_settings # PeerNotifySettings self.pinned = pinned # flags.2?true self.unread_mark = unread_mark # flags.3?true self.view_forum_as_messages = view_forum_as_messages # flags.6?true self.pts = pts # flags.0?int self.draft = draft # flags.1?DraftMessage self.folder_id = folder_id # flags.4?int self.ttl_period = ttl_period # flags.5?int @staticmethod def read(b: BytesIO, *args: Any) -> "Dialog": flags = Int.read(b) pinned = True if flags & (1 << 2) else False unread_mark = True if flags & (1 << 3) else False view_forum_as_messages = True if flags & (1 << 6) else False peer = TLObject.read(b) top_message = Int.read(b) read_inbox_max_id = Int.read(b) read_outbox_max_id = Int.read(b) unread_count = Int.read(b) unread_mentions_count = Int.read(b) unread_reactions_count = Int.read(b) unread_poll_votes_count = Int.read(b) notify_settings = TLObject.read(b) pts = Int.read(b) if flags & (1 << 0) else None draft = TLObject.read(b) if flags & (1 << 1) else None folder_id = Int.read(b) if flags & (1 << 4) else None ttl_period = Int.read(b) if flags & (1 << 5) else None return Dialog(peer=peer, top_message=top_message, read_inbox_max_id=read_inbox_max_id, read_outbox_max_id=read_outbox_max_id, unread_count=unread_count, unread_mentions_count=unread_mentions_count, unread_reactions_count=unread_reactions_count, unread_poll_votes_count=unread_poll_votes_count, notify_settings=notify_settings, pinned=pinned, unread_mark=unread_mark, view_forum_as_messages=view_forum_as_messages, pts=pts, draft=draft, folder_id=folder_id, ttl_period=ttl_period) def write(self, *args) -> bytes: b = BytesIO() b.write(Int(self.ID, False)) flags = 0 flags |= (1 << 2) if self.pinned else 0 flags |= (1 << 3) if self.unread_mark else 0 flags |= (1 << 6) if self.view_forum_as_messages else 0 flags |= (1 << 0) if self.pts is not None else 0 flags |= (1 << 1) if self.draft is not None else 0 flags |= (1 << 4) if self.folder_id is not None else 0 flags |= (1 << 5) if self.ttl_period is not None else 0 b.write(Int(flags)) b.write(self.peer.write()) b.write(Int(self.top_message)) b.write(Int(self.read_inbox_max_id)) b.write(Int(self.read_outbox_max_id)) b.write(Int(self.unread_count)) b.write(Int(self.unread_mentions_count)) b.write(Int(self.unread_reactions_count)) b.write(Int(self.unread_poll_votes_count)) b.write(self.notify_settings.write()) if self.pts is not None: b.write(Int(self.pts)) if self.draft is not None: b.write(self.draft.write()) if self.folder_id is not None: b.write(Int(self.folder_id)) if self.ttl_period is not None: b.write(Int(self.ttl_period)) return b.getvalue()