Source code for hydrogram.raw.types.page

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

from io import BytesIO

from hydrogram.raw.core.primitives import Int, Long, Int128, Int256, Bool, Bytes, String, Double, Vector
from hydrogram.raw.core import TLObject
from hydrogram 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 Page(TLObject): # type: ignore """Instant view page Constructor of :obj:`~hydrogram.raw.base.Page`. Details: - Layer: ``181`` - ID: ``98657F0D`` Parameters: url (``str``): Original page HTTP URL blocks (List of :obj:`PageBlock <hydrogram.raw.base.PageBlock>`): Page elements (like with HTML elements, only as TL constructors) photos (List of :obj:`Photo <hydrogram.raw.base.Photo>`): Photos in page documents (List of :obj:`Document <hydrogram.raw.base.Document>`): Media in page part (``bool``, *optional*): Indicates that not full page preview is available to the client and it will need to fetch full Instant View from the server using messages.getWebPagePreview. rtl (``bool``, *optional*): Whether the page contains RTL text v2 (``bool``, *optional*): Whether this is an IV v2 page views (``int`` ``32-bit``, *optional*): View count """ __slots__: List[str] = ["url", "blocks", "photos", "documents", "part", "rtl", "v2", "views"] ID = 0x98657f0d QUALNAME = "types.Page" def __init__(self, *, url: str, blocks: List["raw.base.PageBlock"], photos: List["raw.base.Photo"], documents: List["raw.base.Document"], part: Optional[bool] = None, rtl: Optional[bool] = None, v2: Optional[bool] = None, views: Optional[int] = None) -> None: self.url = url # string self.blocks = blocks # Vector<PageBlock> self.photos = photos # Vector<Photo> self.documents = documents # Vector<Document> self.part = part # flags.0?true self.rtl = rtl # flags.1?true self.v2 = v2 # flags.2?true self.views = views # flags.3?int @staticmethod def read(b: BytesIO, *args: Any) -> "Page": flags = Int.read(b) part = True if flags & (1 << 0) else False rtl = True if flags & (1 << 1) else False v2 = True if flags & (1 << 2) else False url = String.read(b) blocks = TLObject.read(b) photos = TLObject.read(b) documents = TLObject.read(b) views = Int.read(b) if flags & (1 << 3) else None return Page(url=url, blocks=blocks, photos=photos, documents=documents, part=part, rtl=rtl, v2=v2, views=views) def write(self, *args) -> bytes: b = BytesIO() b.write(Int(self.ID, False)) flags = 0 flags |= (1 << 0) if self.part else 0 flags |= (1 << 1) if self.rtl else 0 flags |= (1 << 2) if self.v2 else 0 flags |= (1 << 3) if self.views is not None else 0 b.write(Int(flags)) b.write(String(self.url)) b.write(Vector(self.blocks)) b.write(Vector(self.photos)) b.write(Vector(self.documents)) if self.views is not None: b.write(Int(self.views)) return b.getvalue()