forked from kate/uniborg
add some comments
This commit is contained in:
parent
02b2b9d2aa
commit
d6f5514c56
|
@ -57,6 +57,8 @@ PARSED_ENTITIES = (
|
||||||
MessageEntityBold, MessageEntityItalic, MessageEntityCode,
|
MessageEntityBold, MessageEntityItalic, MessageEntityCode,
|
||||||
MessageEntityPre, MessageEntityTextUrl
|
MessageEntityPre, MessageEntityTextUrl
|
||||||
)
|
)
|
||||||
|
# a matcher is a tuple of (regex pattern, parse function)
|
||||||
|
# where the parse function takes the match and returns (text, entity)
|
||||||
MATCHERS = [
|
MATCHERS = [
|
||||||
(DEFAULT_URL_RE, parse_url_match),
|
(DEFAULT_URL_RE, parse_url_match),
|
||||||
(get_tag_parser('**', MessageEntityBold)),
|
(get_tag_parser('**', MessageEntityBold)),
|
||||||
|
@ -105,10 +107,12 @@ def parse(message):
|
||||||
@borg.on(events.NewMessage(outgoing=True))
|
@borg.on(events.NewMessage(outgoing=True))
|
||||||
async def reparse(event):
|
async def reparse(event):
|
||||||
message, msg_entities = await borg._parse_message_text(event.text, parse)
|
message, msg_entities = await borg._parse_message_text(event.text, parse)
|
||||||
|
# filter out entities that we don't generate
|
||||||
old_entities = []
|
old_entities = []
|
||||||
for entity in (event.message.entities or []):
|
for entity in (event.message.entities or []):
|
||||||
if isinstance(entity, PARSED_ENTITIES):
|
if isinstance(entity, PARSED_ENTITIES):
|
||||||
old_entities.append(entity)
|
old_entities.append(entity)
|
||||||
|
|
||||||
if len(old_entities) == len(msg_entities) and event.raw_text == message:
|
if len(old_entities) == len(msg_entities) and event.raw_text == message:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue