mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2026-09-13 04:05:58 +00:00
Update to layer 68
This commit is contained in:
@@ -44,6 +44,14 @@ class ChatIdInvalidError(BadRequestError):
|
||||
)
|
||||
|
||||
|
||||
class ConnectionLangPackInvalid(BadRequestError):
|
||||
def __init__(self, **kwargs):
|
||||
super(Exception, self).__init__(
|
||||
self,
|
||||
'The specified language pack is not valid.'
|
||||
)
|
||||
|
||||
|
||||
class ConnectionLayerInvalidError(BadRequestError):
|
||||
def __init__(self, **kwargs):
|
||||
super(Exception, self).__init__(
|
||||
|
||||
@@ -116,6 +116,8 @@ class TelegramBareClient:
|
||||
system_version=self.session.system_version,
|
||||
app_version=self.session.app_version,
|
||||
lang_code=self.session.lang_code,
|
||||
system_lang_code=self.session.system_lang_code,
|
||||
lang_pack='', # "langPacks are for official apps only"
|
||||
query=query)
|
||||
|
||||
result = self.invoke(
|
||||
|
||||
@@ -65,6 +65,7 @@ class TelegramClient(TelegramBareClient):
|
||||
def __init__(self, session, api_id, api_hash, proxy=None,
|
||||
device_model=None, system_version=None,
|
||||
app_version=None, lang_code=None,
|
||||
system_lang_code=None,
|
||||
timeout=timedelta(seconds=5)):
|
||||
"""Initializes the Telegram client with the specified API ID and Hash.
|
||||
|
||||
@@ -74,10 +75,11 @@ class TelegramClient(TelegramBareClient):
|
||||
session - remember to '.log_out()'!
|
||||
|
||||
Default values for the optional parameters if left as None are:
|
||||
device_model = platform.node()
|
||||
system_version = platform.system()
|
||||
app_version = TelegramClient.__version__
|
||||
lang_code = 'en'
|
||||
device_model = platform.node()
|
||||
system_version = platform.system()
|
||||
app_version = TelegramClient.__version__
|
||||
lang_code = 'en'
|
||||
system_lang_code = lang_code
|
||||
"""
|
||||
if not api_id or not api_hash:
|
||||
raise PermissionError(
|
||||
@@ -118,6 +120,9 @@ class TelegramClient(TelegramBareClient):
|
||||
if lang_code:
|
||||
self.session.lang_code = lang_code
|
||||
|
||||
self.session.system_lang_code = \
|
||||
system_lang_code if system_lang_code else self.session.lang_code
|
||||
|
||||
# Cache "exported" senders 'dc_id: MtProtoSender' and
|
||||
# their corresponding sessions not to recreate them all
|
||||
# the time since it's a (somewhat expensive) process.
|
||||
|
||||
@@ -107,6 +107,8 @@ class JsonSession:
|
||||
self.system_version = session.system_version
|
||||
self.app_version = session.app_version
|
||||
self.lang_code = session.lang_code
|
||||
self.system_lang_code = session.system_lang_code
|
||||
self.lang_pack = session.lang_pack
|
||||
|
||||
else: # str / None
|
||||
self.session_user_id = session_user_id
|
||||
@@ -115,6 +117,8 @@ class JsonSession:
|
||||
self.system_version = platform.system()
|
||||
self.app_version = '1.0' # note: '0' will provoke error
|
||||
self.lang_code = 'en'
|
||||
self.system_lang_code = self.lang_code
|
||||
self.lang_pack = ''
|
||||
|
||||
# Cross-thread safety
|
||||
self._lock = Lock()
|
||||
|
||||
Reference in New Issue
Block a user