From 177d456e792bc1e26c01b01333c259490d4a13ad Mon Sep 17 00:00:00 2001 From: profitroll Date: Fri, 7 Apr 2023 22:01:00 +0200 Subject: [PATCH] Improved entities handling --- modules/handlers/analytics_group.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/handlers/analytics_group.py b/modules/handlers/analytics_group.py index 0c8db51..daae591 100644 --- a/modules/handlers/analytics_group.py +++ b/modules/handlers/analytics_group.py @@ -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