Skip to content

[3.x] Change msg.html_text behaviour #874

Closed
@Olegt0rr

Description

@Olegt0rr

Description

Every time when I use message.html_text in my projects, I use construct like this:

text = message.html_text if (message.text or message.caption) else None

cause with current behavior, calling html_text on None will raise an error TypeError: This message doesn't have any text.

With try I also should use code like this:

try:
    text = message.html_text
except TypeError:
    text = None

Describe the solution you'd like

I'd like to make it return None instead of raising an error.
This way it will be more similar to basic message and caption params behaviour. If it's empty - return None.

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.xIssue or PR for stable 3.x versionbreakingThis breaks backwards-compatibilityenhancementMake it better!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions