This commit is contained in:
rick 2025-08-11 07:37:45 +00:00 committed by GitHub
commit 8ccaf90646
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 9 deletions

View file

@ -91,10 +91,8 @@ class TCP:
)
sock.settimeout(TCP.TIMEOUT)
await self.loop.sock_connect(
sock=sock,
address=destination
)
# fix: Use run_in_executor for socks.socksocket
await self.loop.run_in_executor(None, sock.connect, destination)
sock.setblocking(False)
@ -123,7 +121,7 @@ class TCP:
async def connect(self, address: Tuple[str, int]) -> None:
try:
await asyncio.wait_for(self._connect(address), TCP.TIMEOUT)
except asyncio.TimeoutError: # Re-raise as TimeoutError. asyncio.TimeoutError is deprecated in 3.11
except asyncio.TimeoutError:
raise TimeoutError("Connection timed out")
async def close(self) -> None:

View file

@ -77,7 +77,8 @@ class SendGift:
"""
peer = await self.resolve_peer(chat_id)
text, entities = (await utils.parse_text_entities(self, text, parse_mode, entities)).values()
result = await utils.parse_text_entities(self, text, parse_mode, entities)
text, entities = result["message"], result["entities"]
invoice = raw.types.InputInvoiceStarGift(
peer=peer,

View file

@ -436,13 +436,15 @@ async def parse_text_entities(
entities: List["types.MessageEntity"]
) -> Dict[str, Union[str, List[raw.base.MessageEntity]]]:
if entities:
# Inject the client instance because parsing user mentions requires it
for entity in entities:
entity._client = client
text, entities = text, [await entity.write() for entity in entities] or None
text, entities = text, [await entity.write() for entity in entities] or []
else:
text, entities = (await client.parser.parse(text, parse_mode)).values()
parsed = await client.parser.parse(text, parse_mode)
text, entities = parsed["message"], parsed.get("entities") or []
return {
"message": text,