TelegramBareClient: Add set_proxy() method

This allows to change proxy without recreation of the client instance.
This commit is contained in:
Dmitry D. Chernov 2017-12-28 07:50:49 +10:00
parent a5b1457eee
commit fa64a5f7b8

View File

@ -299,6 +299,13 @@ class TelegramBareClient:
self.disconnect() self.disconnect()
return self.connect() return self.connect()
def set_proxy(proxy):
"""Change the proxy used by the connections.
"""
if self.is_connected():
raise RuntimeError("You can't change the proxy while connected.")
self._sender.connection.conn.proxy = proxy
# endregion # endregion
# region Working with different connections/Data Centers # region Working with different connections/Data Centers