mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-10 19:46:36 +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"""
|
||||
import asyncio
|
||||
import os
|
||||
import struct
|
||||
from hashlib import sha1, sha256
|
||||
|
@ -55,14 +54,19 @@ def strip_text(text, entities):
|
|||
text = text[:-1]
|
||||
|
||||
while text and text[0].isspace():
|
||||
e = entities[0]
|
||||
if e.offset == 0:
|
||||
for i in reversed(range(len(entities))):
|
||||
e = entities[i]
|
||||
if e.offset != 0:
|
||||
e.offset -= 1
|
||||
continue
|
||||
|
||||
if e.length == 1:
|
||||
del entities[0]
|
||||
if not entities:
|
||||
return text.lstrip()
|
||||
else:
|
||||
e.length -= 1
|
||||
|
||||
text = text[1:]
|
||||
|
||||
return text
|
||||
|
|
Loading…
Reference in New Issue
Block a user