from ...tl.mtproto_request import MTProtoRequest


class BotInlineMessageMediaVenue(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    botInlineMessageMediaVenue#4366232e flags:# geo:GeoPoint title:string address:string provider:string venue_id:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage"""

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

    def __init__(self, geo, title, address, provider, venue_id, reply_markup=None):
        """
        :param geo: Telegram type: «GeoPoint».
        :param title: Telegram type: «string».
        :param address: Telegram type: «string».
        :param provider: Telegram type: «string».
        :param venue_id: Telegram type: «string».
        :param reply_markup: Telegram type: «ReplyMarkup».

        Constructor for BotInlineMessage: Instance of either BotInlineMessageMediaAuto, BotInlineMessageText, BotInlineMessageMediaGeo, BotInlineMessageMediaVenue, BotInlineMessageMediaContact.
        """
        super().__init__()

        self.geo = geo
        self.title = title
        self.address = address
        self.provider = provider
        self.venue_id = venue_id
        self.reply_markup = reply_markup

    def on_send(self, writer):
        writer.write_int(BotInlineMessageMediaVenue.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)
        writer.tgwrite_string(self.title)
        writer.tgwrite_string(self.address)
        writer.tgwrite_string(self.provider)
        writer.tgwrite_string(self.venue_id)
        if self.reply_markup:
            self.reply_markup.on_send(writer)

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

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

        self.geo = reader.tgread_object()
        self.title = reader.tgread_string()
        self.address = reader.tgread_string()
        self.provider = reader.tgread_string()
        self.venue_id = reader.tgread_string()
        if (flags & (1 << 2)) != 0:
            self.reply_markup = reader.tgread_object()

    def __repr__(self):
        return 'botInlineMessageMediaVenue#4366232e flags:# geo:GeoPoint title:string address:string provider:string venue_id:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage'

    def __str__(self):
        return '(botInlineMessageMediaVenue (ID: 0x4366232e) = (geo={}, title={}, address={}, provider={}, venue_id={}, reply_markup={}))'.format(str(self.geo), str(self.title), str(self.address), str(self.provider), str(self.venue_id), str(self.reply_markup))
