Add init_connection_params parameter to Client class

This commit is contained in:
KurimuzonAkuma 2024-02-20 01:44:36 +03:00
parent 40ddcbca60
commit 52c0fa961b
2 changed files with 8 additions and 1 deletions

View File

@ -189,6 +189,10 @@ class Client(Methods):
storage_engine (:obj:`~pyrogram.storage.Storage`, *optional*): storage_engine (:obj:`~pyrogram.storage.Storage`, *optional*):
Pass an instance of your own implementation of session storage engine. Pass an instance of your own implementation of session storage engine.
Useful when you want to store your session in databases like Mongo, Redis, etc. Useful when you want to store your session in databases like Mongo, Redis, etc.
init_connection_params (:obj:`~raw.base.JSONValue`, *optional*):
Additional initConnection parameters.
For now, only the tz_offset field is supported, for specifying timezone offset in seconds.
""" """
APP_VERSION = f"Pyrogram {__version__}" APP_VERSION = f"Pyrogram {__version__}"
@ -242,7 +246,8 @@ class Client(Methods):
sleep_threshold: int = Session.SLEEP_THRESHOLD, sleep_threshold: int = Session.SLEEP_THRESHOLD,
hide_password: bool = False, hide_password: bool = False,
max_concurrent_transmissions: int = MAX_CONCURRENT_TRANSMISSIONS, max_concurrent_transmissions: int = MAX_CONCURRENT_TRANSMISSIONS,
storage_engine: Storage = None storage_engine: Storage = None,
init_connection_params: "raw.base.JSONValue" = None,
): ):
super().__init__() super().__init__()
@ -273,6 +278,7 @@ class Client(Methods):
self.sleep_threshold = sleep_threshold self.sleep_threshold = sleep_threshold
self.hide_password = hide_password self.hide_password = hide_password
self.max_concurrent_transmissions = max_concurrent_transmissions self.max_concurrent_transmissions = max_concurrent_transmissions
self.init_connection_params = init_connection_params
self.executor = ThreadPoolExecutor(self.workers, thread_name_prefix="Handler") self.executor = ThreadPoolExecutor(self.workers, thread_name_prefix="Handler")

View File

@ -129,6 +129,7 @@ class Session:
lang_pack=self.client.lang_pack, lang_pack=self.client.lang_pack,
lang_code=self.client.lang_code, lang_code=self.client.lang_code,
query=raw.functions.help.GetConfig(), query=raw.functions.help.GetConfig(),
params=self.client.init_connection_params,
) )
), ),
timeout=self.START_TIMEOUT timeout=self.START_TIMEOUT