mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
Merge d6b2227e02 into cb38d6a02b
This commit is contained in:
commit
8ccaf90646
3 changed files with 10 additions and 9 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue