Skip to content

Commit cbafdc2

Browse files
jsmnbomtsnoam
authored andcommitted
Fix Message.text_*
Didn't work with URL type MessageEntities (when you type a url in a tg client and tg converts it to a link for you)
1 parent ebb2556 commit cbafdc2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

telegram/message.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,8 @@ def text_html(self):
673673

674674
if entity.type == MessageEntity.TEXT_LINK:
675675
insert = '<a href="{}">{}</a>'.format(entity.url, text)
676+
elif entity.type == MessageEntity.URL:
677+
insert = '<a href="{0}">{0}</a>'.format(text)
676678
elif entity.type == MessageEntity.BOLD:
677679
insert = '<b>' + text + '</b>'
678680
elif entity.type == MessageEntity.ITALIC:
@@ -723,6 +725,8 @@ def text_markdown(self):
723725

724726
if entity.type == MessageEntity.TEXT_LINK:
725727
insert = '[{}]({})'.format(text, entity.url)
728+
elif entity.type == MessageEntity.URL:
729+
insert = '[{0}]({0})'.format(text)
726730
elif entity.type == MessageEntity.BOLD:
727731
insert = '*' + text + '*'
728732
elif entity.type == MessageEntity.ITALIC:

0 commit comments

Comments
 (0)