mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-23 01:46:35 +03:00
Update init params to match those of tdesktop (#1549)
This commit is contained in:
parent
8cbaacabdb
commit
1afb5b95e3
|
@ -1,4 +1,5 @@
|
||||||
import abc
|
import abc
|
||||||
|
import re
|
||||||
import asyncio
|
import asyncio
|
||||||
import collections
|
import collections
|
||||||
import logging
|
import logging
|
||||||
|
@ -161,11 +162,11 @@ class TelegramBaseClient(abc.ABC):
|
||||||
|
|
||||||
device_model (`str`, optional):
|
device_model (`str`, optional):
|
||||||
"Device model" to be sent when creating the initial connection.
|
"Device model" to be sent when creating the initial connection.
|
||||||
Defaults to ``platform.node()``.
|
Defaults to 'PC (n)bit' derived from ``platform.uname().machine``, or its direct value if unknown.
|
||||||
|
|
||||||
system_version (`str`, optional):
|
system_version (`str`, optional):
|
||||||
"System version" to be sent when creating the initial connection.
|
"System version" to be sent when creating the initial connection.
|
||||||
Defaults to ``platform.system()``.
|
Defaults to ``platform.uname().release`` stripped of everything ahead of -.
|
||||||
|
|
||||||
app_version (`str`, optional):
|
app_version (`str`, optional):
|
||||||
"App version" to be sent when creating the initial connection.
|
"App version" to be sent when creating the initial connection.
|
||||||
|
@ -320,11 +321,19 @@ class TelegramBaseClient(abc.ABC):
|
||||||
# Used on connection. Capture the variables in a lambda since
|
# Used on connection. Capture the variables in a lambda since
|
||||||
# exporting clients need to create this InvokeWithLayerRequest.
|
# exporting clients need to create this InvokeWithLayerRequest.
|
||||||
system = platform.uname()
|
system = platform.uname()
|
||||||
|
|
||||||
|
if system.machine in ('x86_64', 'AMD64'):
|
||||||
|
default_device_model = 'PC 64bit'
|
||||||
|
elif system.machine in ('i386','i686','x86'):
|
||||||
|
default_device_model = 'PC 32bit'
|
||||||
|
else:
|
||||||
|
default_device_model = system.machine
|
||||||
|
default_system_version = re.sub(r'-.+','',system.release)
|
||||||
self._init_with = lambda x: functions.InvokeWithLayerRequest(
|
self._init_with = lambda x: functions.InvokeWithLayerRequest(
|
||||||
LAYER, functions.InitConnectionRequest(
|
LAYER, functions.InitConnectionRequest(
|
||||||
api_id=self.api_id,
|
api_id=self.api_id,
|
||||||
device_model=device_model or system.system or 'Unknown',
|
device_model=device_model or default_device_model or 'Unknown',
|
||||||
system_version=system_version or system.release or '1.0',
|
system_version=system_version or default_system_version or '1.0',
|
||||||
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,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user