Skip to content

Commit ca81249

Browse files
committed
Merge branch 'dev' into test
# Conflicts: # pyrogram/client.py # pyrogram/connection/connection.py # pyrogram/connection/transport/__init__.py # pyrogram/connection/transport/tcp/tcp.py # pyrogram/connection/transport/ws/__init__.py # pyrogram/session/session.py
2 parents b1b1948 + 19aeac6 commit ca81249

42 files changed

Lines changed: 1404 additions & 62 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/python.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
os: [ubuntu-latest, macos-latest]
12-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
12+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
1313

1414
steps:
1515
- uses: actions/checkout@v4
@@ -22,7 +22,6 @@ jobs:
2222
- name: Install dependencies
2323
run: |
2424
python -m pip install --upgrade pip
25-
pip install tox
2625
2726
- name: Generate API
2827
run: |
@@ -31,4 +30,5 @@ jobs:
3130
3231
- name: Run tests
3332
run: |
34-
tox
33+
venv/bin/pip install pytest pytest-asyncio pytest-cov
34+
venv/bin/python -m pytest tests/

compiler/api/source/main_api.tl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Merged TL schema — layer 224
2-
// Generated: 2026-04-08 00:46:08 UTC
2+
// Generated: 2026-04-11 00:44:15 UTC
33
// Sources:
44
// tdlib: https://raw.githubusercontent.com/tdlib/td/refs/heads/master/td/generate/scheme/telegram_api.tl
55
// tdesktop: https://raw.githubusercontent.com/telegramdesktop/tdesktop/refs/heads/dev/Telegram/SourceFiles/mtproto/scheme/api.tl

compiler/enums/source/enums.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,14 @@
11841184
{
11851185
"name": "CHAT_HAS_PROTECTED_CONTENT_DISABLE_REQUESTED",
11861186
"doc": "Chat has protected content disable requested"
1187+
},
1188+
{
1189+
"name": "POLL_OPTION_ADDED",
1190+
"doc": "Poll option added"
1191+
},
1192+
{
1193+
"name": "POLL_OPTION_DELETED",
1194+
"doc": "Poll option deleted"
11871195
}
11881196
]
11891197
},

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ docs = [
8686
"sphinx-design"
8787
]
8888

89+
ws = [
90+
"aiohttp>=3.9",
91+
]
92+
8993
[tool.hatch.version]
9094
path = "pyrogram/__init__.py"
9195

pyrogram/connection/endpoint_selector.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,9 @@ async def _probe(
105105
port: int,
106106
ipv6: bool,
107107
proxy: Optional[dict],
108-
loop: asyncio.AbstractEventLoop,
109108
) -> Optional[float]:
110109
start = time.perf_counter()
111-
protocol = protocol_factory(ipv6=ipv6, proxy=proxy, crypto_executor_workers=1, loop=loop)
110+
protocol = protocol_factory(ipv6=ipv6, proxy=proxy, crypto_executor_workers=1)
112111
try:
113112
await asyncio.wait_for(protocol.connect((ip, port)), timeout=self.PROBE_TIMEOUT_S)
114113
except Exception as e:
@@ -170,7 +169,6 @@ async def select(
170169
dc.port,
171170
dc.ipv6,
172171
getattr(client, "proxy", None),
173-
client.loop,
174172
)
175173
)
176174
for dc in probe_list

pyrogram/connection/transport/tcp/tcp_abridged.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
import asyncio
2019
import logging
2120
from typing import Optional, Tuple, Union
2221

@@ -31,9 +30,8 @@ def __init__(
3130
ipv6: bool = False,
3231
proxy: Optional[Union[str, ProxyDict]] = None,
3332
crypto_executor_workers: int = 1,
34-
loop: Optional[asyncio.AbstractEventLoop] = None,
3533
) -> None:
36-
super().__init__(ipv6, proxy, crypto_executor_workers, loop)
34+
super().__init__(ipv6, proxy, crypto_executor_workers)
3735

3836
async def connect(self, address: Tuple[str, int]) -> None:
3937
self.marker_event.clear()

pyrogram/connection/transport/tcp/tcp_abridged_o.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,15 @@
3030

3131

3232
class TCPAbridgedO(TCP):
33-
RESERVED = (b"HEAD", b"POST", b"GET ", b"OPTI", b"\xee" * 4)
33+
RESERVED = (b"HEAD", b"POST", b"GET ", b"OPTI", b"\xee" * 4, b"\xdd" * 4)
3434

3535
def __init__(
3636
self,
3737
ipv6: bool,
3838
proxy: Union[str, ProxyDict, None] = None,
3939
crypto_executor_workers: int = 1,
40-
loop: Optional[asyncio.AbstractEventLoop] = None,
4140
) -> None:
42-
super().__init__(ipv6, proxy, crypto_executor_workers, loop)
41+
super().__init__(ipv6, proxy, crypto_executor_workers)
4342

4443
self.encrypt = None
4544
self.decrypt = None
@@ -77,7 +76,7 @@ async def send(self, data: bytes, *args, request_ack: bool = False) -> None:
7776
else:
7877
header = (b"\xff" if request_ack else b"\x7f") + length.to_bytes(3, "little")
7978

80-
payload = await self.loop.run_in_executor(
79+
payload = await asyncio.get_event_loop().run_in_executor(
8180
self.crypto_executor, aes.ctr256_encrypt, header + data, *self.encrypt
8281
)
8382
await super().send(payload)
@@ -112,6 +111,6 @@ async def recv(self, length: int = 0) -> Optional[bytes]:
112111
if data is None:
113112
return None
114113

115-
return await self.loop.run_in_executor(
114+
return await asyncio.get_event_loop().run_in_executor(
116115
self.crypto_executor, aes.ctr256_decrypt, data, *self.decrypt
117116
)

pyrogram/connection/transport/tcp/tcp_full.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
import asyncio
2019
import logging
2120
from binascii import crc32
2221
from struct import pack, unpack
@@ -33,9 +32,8 @@ def __init__(
3332
ipv6: bool,
3433
proxy: Union[str, ProxyDict, None] = None,
3534
crypto_executor_workers: int = 1,
36-
loop: Optional[asyncio.AbstractEventLoop] = None,
3735
) -> None:
38-
super().__init__(ipv6, proxy, crypto_executor_workers, loop)
36+
super().__init__(ipv6, proxy, crypto_executor_workers)
3937

4038
self.seq_no: int = 0
4139

pyrogram/connection/transport/tcp/tcp_intermediate.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
import asyncio
2019
import logging
2120
from struct import pack, unpack
2221
from typing import Optional, Tuple, Union
@@ -32,9 +31,8 @@ def __init__(
3231
ipv6: bool,
3332
proxy: Union[str, ProxyDict, None] = None,
3433
crypto_executor_workers: int = 1,
35-
loop: Optional[asyncio.AbstractEventLoop] = None,
3634
) -> None:
37-
super().__init__(ipv6, proxy, crypto_executor_workers, loop)
35+
super().__init__(ipv6, proxy, crypto_executor_workers)
3836

3937
async def connect(self, address: Tuple[str, int]) -> None:
4038
self.marker_event.clear()

pyrogram/connection/transport/tcp/tcp_intermediate_o.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,15 @@
3030

3131

3232
class TCPIntermediateO(TCP):
33-
RESERVED = (b"HEAD", b"POST", b"GET ", b"OPTI", b"\xee" * 4)
33+
RESERVED = (b"HEAD", b"POST", b"GET ", b"OPTI", b"\xee" * 4, b"\xdd" * 4)
3434

3535
def __init__(
3636
self,
3737
ipv6: bool,
3838
proxy: Union[str, ProxyDict, None] = None,
3939
crypto_executor_workers: int = 1,
40-
loop: Optional[asyncio.AbstractEventLoop] = None,
4140
) -> None:
42-
super().__init__(ipv6, proxy, crypto_executor_workers, loop)
41+
super().__init__(ipv6, proxy, crypto_executor_workers)
4342

4443
self.encrypt = None
4544
self.decrypt = None
@@ -73,7 +72,7 @@ async def send(self, data: bytes, *args, request_ack: bool = False) -> None:
7372
length = len(data)
7473
if request_ack:
7574
length |= 0x80000000
76-
payload = await self.loop.run_in_executor(
75+
payload = await asyncio.get_event_loop().run_in_executor(
7776
self.crypto_executor, aes.ctr256_encrypt, pack("<I", length) + data, *self.encrypt
7877
)
7978
await super().send(payload)
@@ -98,6 +97,6 @@ async def recv(self, length: int = 0) -> Optional[bytes]:
9897
if data is None:
9998
return None
10099

101-
return await self.loop.run_in_executor(
100+
return await asyncio.get_event_loop().run_in_executor(
102101
self.crypto_executor, aes.ctr256_decrypt, data, *self.decrypt
103102
)

0 commit comments

Comments
 (0)