mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 19:03:46 +03:00
Fix aaee092
to correct entities' offsets on stripping
This commit is contained in:
parent
424079aa12
commit
40730e7862
|
@ -1,5 +1,4 @@
|
||||||
"""Various helpers not related to the Telegram API itself"""
|
"""Various helpers not related to the Telegram API itself"""
|
||||||
import asyncio
|
|
||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
from hashlib import sha1, sha256
|
from hashlib import sha1, sha256
|
||||||
|
@ -55,14 +54,19 @@ def strip_text(text, entities):
|
||||||
text = text[:-1]
|
text = text[:-1]
|
||||||
|
|
||||||
while text and text[0].isspace():
|
while text and text[0].isspace():
|
||||||
e = entities[0]
|
for i in reversed(range(len(entities))):
|
||||||
if e.offset == 0:
|
e = entities[i]
|
||||||
|
if e.offset != 0:
|
||||||
|
e.offset -= 1
|
||||||
|
continue
|
||||||
|
|
||||||
if e.length == 1:
|
if e.length == 1:
|
||||||
del entities[0]
|
del entities[0]
|
||||||
if not entities:
|
if not entities:
|
||||||
return text.lstrip()
|
return text.lstrip()
|
||||||
else:
|
else:
|
||||||
e.length -= 1
|
e.length -= 1
|
||||||
|
|
||||||
text = text[1:]
|
text = text[1:]
|
||||||
|
|
||||||
return text
|
return text
|
||||||
|
|
Loading…
Reference in New Issue
Block a user