from telethon.tl.mtproto_request import MTProtoRequest


class GetInlineBotResultsRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    messages.getInlineBotResults#514e999d flags:None bot:InputUser peer:InputPeer geo_point:flags.0?InputGeoPoint query:string offset:string = messages.BotResults"""

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

    def __init__(self, bot, peer, query, offset, geo_point=None):
        """
        :param bot: Telegram type: «InputUser».
        :param peer: Telegram type: «InputPeer».
        :param geo_point: Telegram type: «InputGeoPoint».
        :param query: Telegram type: «string».
        :param offset: Telegram type: «string».
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.bot = bot
        self.peer = peer
        self.geo_point = geo_point
        self.query = query
        self.offset = offset

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

        self.bot.on_send(writer)
        self.peer.on_send(writer)
        if self.geo_point:
            self.geo_point.on_send(writer)

        writer.tgwrite_string(self.query)
        writer.tgwrite_string(self.offset)

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

    def on_response(self, reader):
        self.result = reader.tgread_object()

    def __repr__(self):
        return 'messages.getInlineBotResults#514e999d flags:None bot:InputUser peer:InputPeer geo_point:flags.0?InputGeoPoint query:string offset:string = messages.BotResults'

    def __str__(self):
        return '(messages.getInlineBotResults (ID: 0x514e999d) = (bot={}, peer={}, geo_point={}, query={}, offset={}))'.format(str(self.bot), str(self.peer), str(self.geo_point), str(self.query), str(self.offset))
