From fe941cb940d44de0444cb51febbe20a8db9badbc Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 15 Jan 2022 13:41:17 +0100 Subject: [PATCH] Address immutability issues on connect --- telethon/_client/telegrambaseclient.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/telethon/_client/telegrambaseclient.py b/telethon/_client/telegrambaseclient.py index e4906fbf..8ed1a599 100644 --- a/telethon/_client/telegrambaseclient.py +++ b/telethon/_client/telegrambaseclient.py @@ -7,6 +7,7 @@ import platform import time import typing import ipaddress +import dataclasses from .. import version, __name__ as __base_name__, _tl from .._crypto import rsa @@ -342,7 +343,7 @@ async def connect(self: 'TelegramClient') -> None: return if self._sender.auth_key.key != dc.auth: - dc.auth = self._sender.auth_key.key + dc = dataclasses.replace(dc, auth=self._sender.auth_key.key) # Need to send invokeWithLayer for things to work out. # Make the most out of this opportunity by also refreshing our state. @@ -359,11 +360,10 @@ async def connect(self: 'TelegramClient') -> None: ip = int(ipaddress.ip_address(dc.ip_address)) if dc.id in self._all_dcs: - self._all_dcs[dc.id].port = dc.port if dc.ipv6: - self._all_dcs[dc.id].ipv6 = ip + self._all_dcs[dc.id] = dataclasses.replace(self._all_dcs[dc.id], port=dc.port, ipv6=ip) else: - self._all_dcs[dc.id].ipv4 = ip + self._all_dcs[dc.id] = dataclasses.replace(self._all_dcs[dc.id], port=dc.port, ipv4=ip) elif dc.ipv6: self._all_dcs[dc.id] = DataCenter(dc.id, None, ip, dc.port, b'') else: