Example text message I received on telegram:
Listen to best music: Ava Max - My Head & My Heart
My question is, how can my script check the message and eventually open the site via nested link? I tried:
for entity in event.message.text:
if isinstance(entity, MessageEntityTextUrl):
open_url(entity.url)
but no luck - Script doesn't open the link.
//Edit implemented watzon's solution:
async def my_event_handler(event):
msg = event.message.message
for _, inner_text in msg.get_entities_text(MessageEntityTextUrl):
open_url(inner_text)
and now the error is:
...in my_event_handler
for _, inner_text in msg.get_entities_text(MessageEntityTextUrl):
AttributeError: 'str' object has no attribute 'get_entities_text'
I must have missed my mistake here, what should I change in the msg?
//Edit2
msg = event.message
fixed the error but I still don't get the link as output.