Source code for pyrogram.raw.types.poll_answer

#  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 PollAnswer(TLObject): # type: ignore """A possible answer of a poll Constructor of :obj:`~pyrogram.raw.base.PollAnswer`. Details: - Layer: ``229`` - ID: ``4B7D786A`` Parameters: text (:obj:`TextWithEntities <pyrogram.raw.base.TextWithEntities>`): Textual representation of the answer (only `Premium <https://core.telegram.org/api/premium>`_ users can use `custom emoji entities <https://core.telegram.org/api/custom-emoji>`_ here). option (``bytes``): The param that has to be passed to `messages.sendVote <https://core.telegram.org/method/messages.sendVote>`_. media (:obj:`MessageMedia <pyrogram.raw.base.MessageMedia>`, *optional*): Optional media attachment displayed alongside the answer added_by (:obj:`Peer <pyrogram.raw.base.Peer>`, *optional*): The peer who added this answer; only set for answers dynamically added to an open-answer poll, see `polls ยป <https://core.telegram.org/api/poll#open-answer-polls>`_ date (``int`` ``32-bit``, *optional*): When this answer was added; only set for answers dynamically added to an open-answer poll """ __slots__: List[str] = ["text", "option", "media", "added_by", "date"] ID = 0x4b7d786a QUALNAME = "types.PollAnswer" def __init__(self, *, text: "raw.base.TextWithEntities", option: bytes, media: "raw.base.MessageMedia" = None, added_by: "raw.base.Peer" = None, date: Optional[int] = None) -> None: self.text = text # TextWithEntities self.option = option # bytes self.media = media # flags.0?MessageMedia self.added_by = added_by # flags.1?Peer self.date = date # flags.1?int @staticmethod def read(b: BytesIO, *args: Any) -> "PollAnswer": flags = Int.read(b) text = TLObject.read(b) option = Bytes.read(b) media = TLObject.read(b) if flags & (1 << 0) else None added_by = TLObject.read(b) if flags & (1 << 1) else None date = Int.read(b) if flags & (1 << 1) else None return PollAnswer(text=text, option=option, media=media, added_by=added_by, date=date) def write(self, *args) -> bytes: b = BytesIO() b.write(Int(self.ID, False)) flags = 0 flags |= (1 << 0) if self.media is not None else 0 flags |= (1 << 1) if self.added_by is not None else 0 flags |= (1 << 1) if self.date is not None else 0 b.write(Int(flags)) b.write(self.text.write()) b.write(Bytes(self.option)) if self.media is not None: b.write(self.media.write()) if self.added_by is not None: b.write(self.added_by.write()) if self.date is not None: b.write(Int(self.date)) return b.getvalue()