mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-05 03:22:29 +00:00
Avoid cyclic imports on older Python versions
This commit is contained in:
@@ -7,13 +7,12 @@ import math
|
||||
import mimetypes
|
||||
import os
|
||||
import re
|
||||
import struct
|
||||
import types
|
||||
from collections import UserList
|
||||
from mimetypes import guess_extension
|
||||
|
||||
from .extensions import markdown, html
|
||||
from .tl import TLObject
|
||||
from .helpers import add_surrogate, del_surrogate
|
||||
from .tl.types import (
|
||||
Channel, ChannelForbidden, Chat, ChatEmpty, ChatForbidden, ChatFull,
|
||||
ChatPhoto, InputPeerChannel, InputPeerChat, InputPeerUser, InputPeerEmpty,
|
||||
@@ -586,19 +585,6 @@ def _fix_peer_id(peer_id):
|
||||
return int(peer_id)
|
||||
|
||||
|
||||
def add_surrogate(text):
|
||||
return ''.join(
|
||||
# SMP -> Surrogate Pairs (Telegram offsets are calculated with these).
|
||||
# See https://en.wikipedia.org/wiki/Plane_(Unicode)#Overview for more.
|
||||
''.join(chr(y) for y in struct.unpack('<HH', x.encode('utf-16le')))
|
||||
if (0x10000 <= ord(x) <= 0x10FFFF) else x for x in text
|
||||
)
|
||||
|
||||
|
||||
def del_surrogate(text):
|
||||
return text.encode('utf-16', 'surrogatepass').decode('utf-16')
|
||||
|
||||
|
||||
def get_inner_text(text, entities):
|
||||
"""
|
||||
Gets the inner text that's surrounded by the given entities.
|
||||
|
Reference in New Issue
Block a user