from telethon.tl.mtproto_request import MTProtoRequest


class BotInlineMessageMediaGeo(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    botInlineMessageMediaGeo#3a8fd8b8 flags:None geo:GeoPoint reply_markup:flags.2?ReplyMarkup = BotInlineMessage"""

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

    def __init__(self, geo, reply_markup=None):
        """
        :param geo: Telegram type: «GeoPoint».
        :param reply_markup: Telegram type: «ReplyMarkup».
        """
        super().__init__()

        self.geo = geo
        self.reply_markup = reply_markup

    def on_send(self, writer):
        writer.write_int(BotInlineMessageMediaGeo.constructor_id, signed=False)
        # Calculate the flags. This equals to those flag arguments which are NOT None
        flags = 0
        flags |= (1 << 2) if self.reply_markup else 0
        writer.write_int(flags)

        self.geo.on_send(writer)
        if self.reply_markup:
            self.reply_markup.on_send(writer)

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

    def on_response(self, reader):
        flags = reader.read_int()

        self.geo = reader.tgread_object()
        if (flags & (1 << 2)) != 0:
            self.reply_markup = reader.tgread_object()

    def __repr__(self):
        return 'botInlineMessageMediaGeo#3a8fd8b8 flags:None geo:GeoPoint reply_markup:flags.2?ReplyMarkup = BotInlineMessage'

    def __str__(self):
        return '(botInlineMessageMediaGeo (ID: 0x3a8fd8b8) = (geo={}, reply_markup={}))'.format(str(self.geo), str(self.reply_markup))
