# 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 StartLive(TLObject): # type: ignore
"""{schema}
Details:
- Layer: ``223``
- ID: ``D069CCDE``
Parameters:
peer (:obj:`InputPeer <hydrogram.raw.base.InputPeer>`):
privacy_rules (List of :obj:`InputPrivacyRule <hydrogram.raw.base.InputPrivacyRule>`):
random_id (``int`` ``64-bit``):
pinned (``bool``, *optional*):
noforwards (``bool``, *optional*):
rtmp_stream (``bool``, *optional*):
caption (``str``, *optional*):
entities (List of :obj:`MessageEntity <hydrogram.raw.base.MessageEntity>`, *optional*):
Message entities for styled text
messages_enabled (``bool``, *optional*):
send_paid_messages_stars (``int`` ``64-bit``, *optional*):
Returns:
:obj:`Updates <hydrogram.raw.base.Updates>`
"""
__slots__: List[str] = ["peer", "privacy_rules", "random_id", "pinned", "noforwards", "rtmp_stream", "caption", "entities", "messages_enabled", "send_paid_messages_stars"]
ID = 0xd069ccde
QUALNAME = "functions.stories.StartLive"
def __init__(self, *, peer: "raw.base.InputPeer", privacy_rules: List["raw.base.InputPrivacyRule"], random_id: int, pinned: Optional[bool] = None, noforwards: Optional[bool] = None, rtmp_stream: Optional[bool] = None, caption: Optional[str] = None, entities: Optional[List["raw.base.MessageEntity"]] = None, messages_enabled: Optional[bool] = None, send_paid_messages_stars: Optional[int] = None) -> None:
self.peer = peer # InputPeer
self.privacy_rules = privacy_rules # Vector<InputPrivacyRule>
self.random_id = random_id # long
self.pinned = pinned # flags.2?true
self.noforwards = noforwards # flags.4?true
self.rtmp_stream = rtmp_stream # flags.5?true
self.caption = caption # flags.0?string
self.entities = entities # flags.1?Vector<MessageEntity>
self.messages_enabled = messages_enabled # flags.6?Bool
self.send_paid_messages_stars = send_paid_messages_stars # flags.7?long
@staticmethod
def read(b: BytesIO, *args: Any) -> "StartLive":
flags = Int.read(b)
pinned = True if flags & (1 << 2) else False
noforwards = True if flags & (1 << 4) else False
rtmp_stream = True if flags & (1 << 5) else False
peer = TLObject.read(b)
caption = String.read(b) if flags & (1 << 0) else None
entities = TLObject.read(b) if flags & (1 << 1) else []
privacy_rules = TLObject.read(b)
random_id = Long.read(b)
messages_enabled = Bool.read(b) if flags & (1 << 6) else None
send_paid_messages_stars = Long.read(b) if flags & (1 << 7) else None
return StartLive(peer=peer, privacy_rules=privacy_rules, random_id=random_id, pinned=pinned, noforwards=noforwards, rtmp_stream=rtmp_stream, caption=caption, entities=entities, messages_enabled=messages_enabled, send_paid_messages_stars=send_paid_messages_stars)
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 << 4) if self.noforwards else 0
flags |= (1 << 5) if self.rtmp_stream else 0
flags |= (1 << 0) if self.caption is not None else 0
flags |= (1 << 1) if self.entities else 0
flags |= (1 << 6) if self.messages_enabled is not None else 0
flags |= (1 << 7) if self.send_paid_messages_stars is not None else 0
b.write(Int(flags))
b.write(self.peer.write())
if self.caption is not None:
b.write(String(self.caption))
if self.entities is not None:
b.write(Vector(self.entities))
b.write(Vector(self.privacy_rules))
b.write(Long(self.random_id))
if self.messages_enabled is not None:
b.write(Bool(self.messages_enabled))
if self.send_paid_messages_stars is not None:
b.write(Long(self.send_paid_messages_stars))
return b.getvalue()