from ...tl.mtproto_request import MTProtoRequest


class KeyboardButtonUrl(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    keyboardButtonUrl#258aff05 text:string url:string = KeyboardButton"""

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

    def __init__(self, text, url):
        """
        :param text: Telegram type: «string».
        :param url: Telegram type: «string».

        Constructor for KeyboardButton: Instance of either KeyboardButton, KeyboardButtonUrl, KeyboardButtonCallback, KeyboardButtonRequestPhone, KeyboardButtonRequestGeoLocation, KeyboardButtonSwitchInline, KeyboardButtonGame, KeyboardButtonBuy.
        """
        super().__init__()

        self.text = text
        self.url = url

    def on_send(self, writer):
        writer.write_int(KeyboardButtonUrl.constructor_id, signed=False)
        writer.tgwrite_string(self.text)
        writer.tgwrite_string(self.url)

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

    def on_response(self, reader):
        self.text = reader.tgread_string()
        self.url = reader.tgread_string()

    def __repr__(self):
        return 'keyboardButtonUrl#258aff05 text:string url:string = KeyboardButton'

    def __str__(self):
        return '(keyboardButtonUrl (ID: 0x258aff05) = (text={}, url={}))'.format(str(self.text), str(self.url))
