from telethon.tl.mtproto_request import MTProtoRequest


class SearchRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    contacts.search#11f812d8 q:string limit:int = contacts.Found"""

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

    def __init__(self, q, limit):
        """
        :param q: Telegram type: «string».
        :param limit: Telegram type: «int».
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.q = q
        self.limit = limit

    def on_send(self, writer):
        writer.write_int(SearchRequest.constructor_id, signed=False)
        writer.tgwrite_string(self.q)
        writer.write_int(self.limit)

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

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

    def __repr__(self):
        return 'contacts.search#11f812d8 q:string limit:int = contacts.Found'

    def __str__(self):
        return '(contacts.search (ID: 0x11f812d8) = (q={}, limit={}))'.format(str(self.q), str(self.limit))
