from telethon.tl.mtproto_request import MTProtoRequest


class MessageMediaPhoto(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    messageMediaPhoto#3d8ce53d photo:Photo caption:string = MessageMedia"""

    # Telegram's constructor ID (and unique identifier) for this class
    constructor_id = 0x3d8ce53d

    def __init__(self, photo, caption):
        """
        :param photo: Telegram type: «Photo».
        :param caption: Telegram type: «string».
        """
        super().__init__()

        self.photo = photo
        self.caption = caption

    def on_send(self, writer):
        writer.write_int(MessageMediaPhoto.constructor_id, signed=False)
        self.photo.on_send(writer)
        writer.tgwrite_string(self.caption)

    @staticmethod
    def empty():
        """Returns an "empty" instance (all attributes are None)"""
        return MessageMediaPhoto(None, None)

    def on_response(self, reader):
        self.photo = reader.tgread_object()
        self.caption = reader.tgread_string()

    def __repr__(self):
        return 'messageMediaPhoto#3d8ce53d photo:Photo caption:string = MessageMedia'

    def __str__(self):
        return '(messageMediaPhoto (ID: 0x3d8ce53d) = (photo={}, caption={}))'.format(str(self.photo), str(self.caption))
