forked from kate/uniborg
Don't count entities that can't be generated
This commit is contained in:
parent
40f85c162b
commit
02b2b9d2aa
|
@ -53,6 +53,10 @@ def parse_snip(m):
|
|||
return m.group(1), None
|
||||
|
||||
|
||||
PARSED_ENTITIES = (
|
||||
MessageEntityBold, MessageEntityItalic, MessageEntityCode,
|
||||
MessageEntityPre, MessageEntityTextUrl
|
||||
)
|
||||
MATCHERS = [
|
||||
(DEFAULT_URL_RE, parse_url_match),
|
||||
(get_tag_parser('**', MessageEntityBold)),
|
||||
|
@ -101,8 +105,11 @@ def parse(message):
|
|||
@borg.on(events.NewMessage(outgoing=True))
|
||||
async def reparse(event):
|
||||
message, msg_entities = await borg._parse_message_text(event.text, parse)
|
||||
|
||||
if len(event.message.entities or []) == len(msg_entities) and event.raw_text == message:
|
||||
old_entities = []
|
||||
for entity in (event.message.entities or []):
|
||||
if isinstance(entity, PARSED_ENTITIES):
|
||||
old_entities.append(entity)
|
||||
if len(old_entities) == len(msg_entities) and event.raw_text == message:
|
||||
return
|
||||
|
||||
await borg(EditMessageRequest(
|
||||
|
|
Loading…
Reference in New Issue