Improved entities handling

This commit is contained in:
Profitroll 2023-04-07 22:01:00 +02:00
parent 7218d580bb
commit 177d456e79

View File

@ -66,8 +66,16 @@ async def msg_destination_group(app: Client, msg: Message):
for entity in entities:
if entity.type == MessageEntityType.TEXT_LINK:
analytics_entry["entities"]["links"].append(entity.url)
elif entity.type == MessageEntityType.URL:
analytics_entry["entities"]["links"].append(
text[entity.offset : entity.offset + entity.length]
)
elif entity.type == MessageEntityType.TEXT_MENTION:
analytics_entry["entities"]["mentions"].append(entity.user.id)
elif entity.type == MessageEntityType.MENTION:
analytics_entry["entities"]["mentions"].append(
text[entity.offset : entity.offset + entity.length]
)
lang = Detector(text, quiet=True).language