change for official

This commit is contained in:
Caihua 2023-06-26 11:51:05 +08:00
parent 16ed9614f9
commit d453e3cd67

View File

@ -27,7 +27,6 @@ if typing.TYPE_CHECKING:
_base_log = logging.getLogger(__base_name__) _base_log = logging.getLogger(__base_name__)
# In seconds, how long to wait before disconnecting a exported sender. # In seconds, how long to wait before disconnecting a exported sender.
_DISCONNECT_EXPORTED_AFTER = 60 _DISCONNECT_EXPORTED_AFTER = 60
@ -374,12 +373,17 @@ class TelegramBaseClient(abc.ABC):
if system.machine in ('x86_64', 'AMD64'): if system.machine in ('x86_64', 'AMD64'):
default_device_model = 'PC 64bit' default_device_model = 'PC 64bit'
elif system.machine in ('i386','i686','x86'): elif system.machine in ('i386', 'i686', 'x86'):
default_device_model = 'PC 32bit' default_device_model = 'PC 32bit'
else: else:
default_device_model = system.machine default_device_model = system.machine
default_system_version = re.sub(r'-.+','',system.release) default_system_version = re.sub(r'-.+', '', system.release)
params = types.JsonObject(value=[types.JsonObjectValue('data', types.JsonString('49C1522548EBACD46CE322B6FD47F6092BB745D0F88082145CAF35E14DCC38E1'))
, types.JsonObjectValue('installer', types.JsonString('org.telegram.messenger'))
, types.JsonObjectValue('device_token', types.JsonString(
'eyCG5O7hS3afOaFaTpO6l2:APA91bHH8rXNO86qW9cdeEq8VtaPQ7dbvVXuQ3niygBajHLtZmOwuFr_w9LwWSd-SzR_4h2HH6zPjLByOZ54x8Qj-m7FQHu1OzAy8Z08IIit9sgb'
'-VMxwX7YzebBiIKsPrwCWzFCqsJK'))
, types.JsonObjectValue('package_id', types.JsonString('org.telegram.messenger'))])
self._init_request = functions.InitConnectionRequest( self._init_request = functions.InitConnectionRequest(
api_id=self.api_id, api_id=self.api_id,
device_model=device_model or default_device_model or 'Unknown', device_model=device_model or default_device_model or 'Unknown',
@ -387,9 +391,10 @@ class TelegramBaseClient(abc.ABC):
app_version=app_version or self.__version__, app_version=app_version or self.__version__,
lang_code=lang_code, lang_code=lang_code,
system_lang_code=system_lang_code, system_lang_code=system_lang_code,
lang_pack='', # "langPacks are for official apps only" lang_pack='android', # "langPacks are for official apps only"
query=None, query=None,
proxy=init_proxy proxy=init_proxy,
params=params
) )
# Remember flood-waited requests to avoid making them again # Remember flood-waited requests to avoid making them again
@ -458,7 +463,6 @@ class TelegramBaseClient(abc.ABC):
auto_reconnect_callback=self._handle_auto_reconnect auto_reconnect_callback=self._handle_auto_reconnect
) )
# endregion # endregion
# region Properties # region Properties
@ -542,12 +546,12 @@ class TelegramBaseClient(abc.ABC):
raise RuntimeError('The asyncio event loop must not change after connection (see the FAQ for details)') raise RuntimeError('The asyncio event loop must not change after connection (see the FAQ for details)')
if not await self._sender.connect(self._connection( if not await self._sender.connect(self._connection(
self.session.server_address, self.session.server_address,
self.session.port, self.session.port,
self.session.dc_id, self.session.dc_id,
loggers=self._log, loggers=self._log,
proxy=self._proxy, proxy=self._proxy,
local_addr=self._local_addr local_addr=self._local_addr
)): )):
# We don't want to init or modify anything if we were already connected # We don't want to init or modify anything if we were already connected
return return