from ...tl.mtproto_request import MTProtoRequest


class InputBotInlineMessageMediaGeo(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    inputBotInlineMessageMediaGeo#f4a59de1 flags:# geo_point:InputGeoPoint reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage"""

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

    def __init__(self, geo_point, reply_markup=None):
        """
        :param geo_point: Telegram type: «InputGeoPoint».
        :param reply_markup: Telegram type: «ReplyMarkup».

        Constructor for InputBotInlineMessage: Instance of either InputBotInlineMessageMediaAuto, InputBotInlineMessageText, InputBotInlineMessageMediaGeo, InputBotInlineMessageMediaVenue, InputBotInlineMessageMediaContact, InputBotInlineMessageGame.
        """
        super().__init__()

        self.geo_point = geo_point
        self.reply_markup = reply_markup

    def on_send(self, writer):
        writer.write_int(InputBotInlineMessageMediaGeo.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_point.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 InputBotInlineMessageMediaGeo(None, None)

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

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

    def __repr__(self):
        return 'inputBotInlineMessageMediaGeo#f4a59de1 flags:# geo_point:InputGeoPoint reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage'

    def __str__(self):
        return '(inputBotInlineMessageMediaGeo (ID: 0xf4a59de1) = (geo_point={}, reply_markup={}))'.format(str(self.geo_point), str(self.reply_markup))
