mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Fixed nested hashtag, cashtag and email message entities not being parsed correctly when these entities are inside another entity.
This commit is contained in:
parent
c516ea9d6a
commit
c8be3da67a
3 changed files with 32 additions and 1 deletions
1
CHANGES/1259.bugfix.rst
Normal file
1
CHANGES/1259.bugfix.rst
Normal file
|
|
@ -0,0 +1 @@
|
|||
Fixed nested hashtag, cashtag and email message entities not being parsed correctly when these entities are inside another entity.
|
||||
|
|
@ -43,8 +43,11 @@ class TextDecoration(ABC):
|
|||
MessageEntityType.URL,
|
||||
MessageEntityType.MENTION,
|
||||
MessageEntityType.PHONE_NUMBER,
|
||||
MessageEntityType.HASHTAG,
|
||||
MessageEntityType.CASHTAG,
|
||||
MessageEntityType.EMAIL,
|
||||
}:
|
||||
# This entities should not be changed
|
||||
# These entities should not be changed
|
||||
return text
|
||||
if entity.type in {
|
||||
MessageEntityType.BOLD,
|
||||
|
|
|
|||
|
|
@ -243,6 +243,33 @@ class TestTextDecoration:
|
|||
[MessageEntity(type="bold", offset=0, length=8, url=None, user=None)],
|
||||
"<b>👋🏾 Hi!</b>",
|
||||
],
|
||||
[
|
||||
html_decoration,
|
||||
"#test",
|
||||
[
|
||||
MessageEntity(type="hashtag", offset=0, length=5),
|
||||
MessageEntity(type="bold", offset=0, length=5),
|
||||
],
|
||||
"<b>#test</b>",
|
||||
],
|
||||
[
|
||||
html_decoration,
|
||||
"$TEST",
|
||||
[
|
||||
MessageEntity(type="cashtag", offset=0, length=5),
|
||||
MessageEntity(type="bold", offset=0, length=5),
|
||||
],
|
||||
"<b>$TEST</b>",
|
||||
],
|
||||
[
|
||||
html_decoration,
|
||||
"test@example.com",
|
||||
[
|
||||
MessageEntity(type="email", offset=0, length=16),
|
||||
MessageEntity(type="bold", offset=0, length=16),
|
||||
],
|
||||
"<b>test@example.com</b>",
|
||||
],
|
||||
],
|
||||
)
|
||||
def test_unparse(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue