from telethon.tl.mtproto_request import MTProtoRequest


class BadServerSalt(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    bad_server_salt#edab447b bad_msg_id:long bad_msg_seqno:int error_code:int new_server_salt:long = BadMsgNotification"""

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

    def __init__(self, bad_msg_id, bad_msg_seqno, error_code, new_server_salt):
        """
        :param bad_msg_id: Telegram type: «long».
        :param bad_msg_seqno: Telegram type: «int».
        :param error_code: Telegram type: «int».
        :param new_server_salt: Telegram type: «long».
        """
        super().__init__()

        self.bad_msg_id = bad_msg_id
        self.bad_msg_seqno = bad_msg_seqno
        self.error_code = error_code
        self.new_server_salt = new_server_salt

    def on_send(self, writer):
        writer.write_int(BadServerSalt.constructor_id, signed=False)
        writer.write_long(self.bad_msg_id)
        writer.write_int(self.bad_msg_seqno)
        writer.write_int(self.error_code)
        writer.write_long(self.new_server_salt)

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

    def on_response(self, reader):
        self.bad_msg_id = reader.read_long()
        self.bad_msg_seqno = reader.read_int()
        self.error_code = reader.read_int()
        self.new_server_salt = reader.read_long()

    def __repr__(self):
        return 'bad_server_salt#edab447b bad_msg_id:long bad_msg_seqno:int error_code:int new_server_salt:long = BadMsgNotification'

    def __str__(self):
        return '(bad_server_salt (ID: 0xedab447b) = (bad_msg_id={}, bad_msg_seqno={}, error_code={}, new_server_salt={}))'.format(str(self.bad_msg_id), str(self.bad_msg_seqno), str(self.error_code), str(self.new_server_salt))
