mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Fixed nested hashtag, cashtag and email entnties parsing (#1263)
* Fixed nested hashtag, cashtag and email message entities not being parsed correctly when these entities are inside another entity. * Tests coverage
This commit is contained in:
parent
020db29e6d
commit
a80031509e
3 changed files with 42 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
@ -71,6 +74,8 @@ class TextDecoration(ABC):
|
|||
if entity.type == MessageEntityType.CUSTOM_EMOJI:
|
||||
return self.custom_emoji(value=text, custom_emoji_id=cast(str, entity.custom_emoji_id))
|
||||
|
||||
# This case is not possible because of `if` above, but if any new entity is added to
|
||||
# API it will be here too
|
||||
return self.quote(text)
|
||||
|
||||
def unparse(self, text: str, entities: Optional[List[MessageEntity]] = None) -> str:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue