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)
|
sock.settimeout(TCP.TIMEOUT)
|
||||||
|
|
||||||
await self.loop.sock_connect(
|
# fix: Use run_in_executor for socks.socksocket
|
||||||
sock=sock,
|
await self.loop.run_in_executor(None, sock.connect, destination)
|
||||||
address=destination
|
|
||||||
)
|
|
||||||
|
|
||||||
sock.setblocking(False)
|
sock.setblocking(False)
|
||||||
|
|
||||||
|
|
@ -123,7 +121,7 @@ class TCP:
|
||||||
async def connect(self, address: Tuple[str, int]) -> None:
|
async def connect(self, address: Tuple[str, int]) -> None:
|
||||||
try:
|
try:
|
||||||
await asyncio.wait_for(self._connect(address), TCP.TIMEOUT)
|
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")
|
raise TimeoutError("Connection timed out")
|
||||||
|
|
||||||
async def close(self) -> None:
|
async def close(self) -> None:
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,8 @@ class SendGift:
|
||||||
"""
|
"""
|
||||||
peer = await self.resolve_peer(chat_id)
|
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(
|
invoice = raw.types.InputInvoiceStarGift(
|
||||||
peer=peer,
|
peer=peer,
|
||||||
|
|
|
||||||
|
|
@ -436,13 +436,15 @@ async def parse_text_entities(
|
||||||
entities: List["types.MessageEntity"]
|
entities: List["types.MessageEntity"]
|
||||||
) -> Dict[str, Union[str, List[raw.base.MessageEntity]]]:
|
) -> Dict[str, Union[str, List[raw.base.MessageEntity]]]:
|
||||||
if entities:
|
if entities:
|
||||||
# Inject the client instance because parsing user mentions requires it
|
|
||||||
for entity in entities:
|
for entity in entities:
|
||||||
entity._client = client
|
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:
|
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 {
|
return {
|
||||||
"message": text,
|
"message": text,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue