Reputation: 1
Anyone knows how to edit entities in pyrogram? Below is a test script that I'm using, I just wanted to edit the 'url' entity of the message thru code but I'm getting an error on utils.py module:
CODE:
async with Client("tg") as tg:
await tg.edit_message_text(
chat_id=board_id,
message_id=123,
text="Happy Birthday!",
entities=[
{
"_": "MessageEntity",
"type": "MessageEntityType.TEXT_LINK",
"offset": 0,
"length": 15,
"url": "https://t.me/c/1234567890/123"
},
]
)
File "C:\Users\tito\maya\pythonProject1\lib\site-packages\pyrogram\methods\utilities\run.py", line 77, in run
run(coroutine)
File "C:\Users\tito\.pyenv\pyenv-win\versions\3.10.7\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\Users\tito\pythonProject1\test2.py", line 45, in main
await tg.edit_message_text(
File "C:\Users\tito\maya\pythonProject1\lib\site-packages\pyrogram\methods\messages\edit_message_text.py", line 88, in edit_message_text
**await utils.parse_text_entities(self, text, parse_mode, entities)
File "C:\Users\tito\maya\pythonProject1\lib\site-packages\pyrogram\utils.py", line 350, in parse_text_entities
entity._client = client
AttributeError: 'dict' object has no attribute '_client'
Process finished with exit code 1
Upvotes: 0
Views: 414
Reputation: 1131
You cannot manually add or edit Message Entities. You can, however, use Markdown or HTML to add styling to your messages.
with Client() as app:
app.send_message(
text="[Link as Markdown](https://example.com)"
)
app.send_message(
text="<a href='https://example.com'>Link as HTML</a>"
)
Upvotes: 0