From a2ccdb2378e947436c0130ceb9ed8601a970916b Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 11 Jan 2022 22:35:38 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=84=20Sync=20local=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/FUNDING.yml | 3 --- .github/workflows/python.yml | 2 +- pyrogram/client.py | 7 +++++++ pyrogram/crypto/rsa.py | 24 +++++++++++++++++++++++ pyrogram/raw/core/gzip_packed.py | 5 ++--- pyrogram/session/auth.py | 3 ++- pyrogram/session/internals/data_center.py | 6 ++---- pyrogram/session/session.py | 4 +++- setup.py | 16 +++++++-------- 9 files changed, 49 insertions(+), 21 deletions(-) delete mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 19d0cd78..00000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,3 +0,0 @@ -github: delivrance -liberapay: delivrance -open_collective: pyrogram diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 89ed8532..ab02b1a6 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: [3.6, 3.7, 3.8, 3.9, "3.10"] + python-version: [3.7, 3.8, 3.9, "3.10", "pypy-3.7", "pypy-3.8"] steps: - uses: actions/checkout@v2 diff --git a/pyrogram/client.py b/pyrogram/client.py index ce76920f..a0ea1b10 100644 --- a/pyrogram/client.py +++ b/pyrogram/client.py @@ -107,6 +107,11 @@ class Client(Methods, Scaffold): Only applicable for new sessions and will be ignored in case previously created sessions are loaded. Defaults to False. + mode (``int``, *optional*): + The connection mode to use. + Defaults to Obfuscated TCPAbridged (3), + The list of modes are available at `connection/connection.py` + bot_token (``str``, *optional*): Pass your Bot API token to create a bot session, e.g.: "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11" Only applicable for new sessions. @@ -188,6 +193,7 @@ class Client(Methods, Scaffold): ipv6: bool = False, proxy: dict = None, test_mode: bool = False, + mode: int = 3, bot_token: str = None, phone_number: str = None, phone_code: str = None, @@ -216,6 +222,7 @@ class Client(Methods, Scaffold): # TODO: Make code consistent, use underscore for private/protected fields self._proxy = proxy self.test_mode = test_mode + self.mode = mode self.bot_token = bot_token self.phone_number = phone_number self.phone_code = phone_code diff --git a/pyrogram/crypto/rsa.py b/pyrogram/crypto/rsa.py index 3fd7d67b..129f3124 100644 --- a/pyrogram/crypto/rsa.py +++ b/pyrogram/crypto/rsa.py @@ -199,6 +199,30 @@ server_public_keys = { 16 ), # Modulus int("010001", 16) # Exponent + ), + + # -5741912883845771609 + 0xb050a0a773224ea7 - (1 << 64): PublicKey( # MTPager DEV + # -----BEGIN RSA PUBLIC KEY----- + # MIIBCgKCAQEAyY9aW/0U3Vpju5QWHi46n7OFHZnRfDRP34mX4k6xnK4xY14phjqa + # Slt0Jr37o/fLXyXCDSX3HoAG1uRNMiXss7luC1qkQBME8dHGWCprbkfjrh7HkrEd + # UkKU7FkSPqwVqEaNGwO8xedGXJYcZflVqDNA3V+prPSRvrsRw5aCXOxJvKy1AhVi + # fKCh+z59cMvn/H6U51H9E3+iAg0VkF5nQ+yemjP8BJ+/B2Be3TOMcQyEVC19JLj8 + # EwBdYAVtEQbwYfjvhkU8m0PMYgCcg4jqKT/G4Z6vJd3Pd8ml/dkmcgz+OS5hOesk + # 9yJ+u5S2J86nLEJcPxajvOJ05GFpBZY/rQIDAQAB + # -----END RSA PUBLIC KEY----- + int( + "C98F5A5BFD14DD5A63BB94161E2E3A9FB3851D99D17C344FDF8997E24EB19CAE" + "31635E29863A9A4A5B7426BDFBA3F7CB5F25C20D25F71E8006D6E44D3225ECB3" + "B96E0B5AA4401304F1D1C6582A6B6E47E3AE1EC792B11D524294EC59123EAC15" + "A8468D1B03BCC5E7465C961C65F955A83340DD5FA9ACF491BEBB11C396825CEC" + "49BCACB50215627CA0A1FB3E7D70CBE7FC7E94E751FD137FA2020D15905E6743" + "EC9E9A33FC049FBF07605EDD338C710C84542D7D24B8FC13005D60056D1106F0" + "61F8EF86453C9B43CC62009C8388EA293FC6E19EAF25DDCF77C9A5FDD926720C" + "FE392E6139EB24F7227EBB94B627CEA72C425C3F16A3BCE274E4616905963FAD", + 16 + ), # Modulus + int("010001", 16) # Exponent ) } diff --git a/pyrogram/raw/core/gzip_packed.py b/pyrogram/raw/core/gzip_packed.py index 685594d8..a2750eab 100644 --- a/pyrogram/raw/core/gzip_packed.py +++ b/pyrogram/raw/core/gzip_packed.py @@ -18,7 +18,7 @@ from gzip import compress, decompress from io import BytesIO -from typing import cast, Any +from typing import Any from .primitives.bytes import Bytes from .primitives.int import Int @@ -37,8 +37,7 @@ class GzipPacked(TLObject): @staticmethod def read(data: BytesIO, *args: Any) -> "GzipPacked": - # Return the Object itself instead of a GzipPacked wrapping it - return cast(GzipPacked, TLObject.read( + return GzipPacked(TLObject.read( BytesIO( decompress( Bytes.read(data) diff --git a/pyrogram/session/auth.py b/pyrogram/session/auth.py index d4083b21..6187a85d 100644 --- a/pyrogram/session/auth.py +++ b/pyrogram/session/auth.py @@ -42,6 +42,7 @@ class Auth: self.test_mode = test_mode self.ipv6 = client.ipv6 self.proxy = client.proxy + self.mode = client.mode self.connection = None @@ -76,7 +77,7 @@ class Auth: # The server may close the connection at any time, causing the auth key creation to fail. # If that happens, just try again up to MAX_RETRIES times. while True: - self.connection = Connection(self.dc_id, self.test_mode, self.ipv6, self.proxy) + self.connection = Connection(self.dc_id, self.test_mode, self.ipv6, self.proxy, False, self.mode) try: log.info(f"Start creating a new auth key on DC{self.dc_id}") diff --git a/pyrogram/session/internals/data_center.py b/pyrogram/session/internals/data_center.py index 4fce19aa..03cc3046 100644 --- a/pyrogram/session/internals/data_center.py +++ b/pyrogram/session/internals/data_center.py @@ -21,9 +21,7 @@ from typing import Tuple class DataCenter: TEST = { - 1: "149.154.175.10", - 2: "149.154.167.40", - 3: "149.154.175.117", + 2: "tg.dev01.0s.hk", } PROD = { @@ -65,7 +63,7 @@ class DataCenter: else: ip = cls.TEST[dc_id] - return ip, 80 + return ip, 443 else: if ipv6: if media: diff --git a/pyrogram/session/session.py b/pyrogram/session/session.py index 751d6e00..6eb53e82 100644 --- a/pyrogram/session/session.py +++ b/pyrogram/session/session.py @@ -68,6 +68,7 @@ class Session: self.test_mode = test_mode self.is_media = is_media self.is_cdn = is_cdn + self.mode = client.mode self.connection = None @@ -103,7 +104,8 @@ class Session: self.test_mode, self.client.ipv6, self.client.proxy, - self.is_media + self.is_media, + self.mode ) try: diff --git a/setup.py b/setup.py index 1a24654c..1fca776e 100644 --- a/setup.py +++ b/setup.py @@ -131,13 +131,13 @@ if len(argv) > 1 and argv[1] in ["bdist_wheel", "install", "develop"]: errors_compiler.start() setup( - name="Pyrogram", + name="MTPyroger", version=version, - description="Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots", + description="A Pyrogram for MTPager for testing purposes", long_description=readme, long_description_content_type="text/markdown", - url="https://github.com/pyrogram", - download_url="https://github.com/pyrogram/pyrogram/releases/latest", + url="https://github.com/Xtao-Labs", + download_url="https://github.com/Xtao-Labs/pyrogram/releases/latest", author="Dan", author_email="dan@pyrogram.org", license="LGPLv3+", @@ -164,11 +164,11 @@ setup( "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Libraries :: Application Frameworks" ], - keywords="telegram chat messenger mtproto api client library python", + keywords="mtpager pagermaid", project_urls={ - "Tracker": "https://github.com/pyrogram/pyrogram/issues", - "Community": "https://t.me/pyrogram", - "Source": "https://github.com/pyrogram/pyrogram", + "Tracker": "https://github.com/Xtao-Labs/pyrogram/issues", + "Community": "https://t.me/PagerMaid_Modify", + "Source": "https://github.com/Xtao-Labs/pyrogram", "Documentation": "https://docs.pyrogram.org", }, python_requires="~=3.6",