Skip to content

whatsapie/ext/message/text.py

Text

Bases: Message

Inherits from Message class.

Inherits from Message class, represents a Text Message api object.

Parameters:

Name Type Description Default
body str

Message body text.

required
preview_url bool

Must be set to true, when you want to render the embed for the url in the body.

False
Source code in whatsapie/ext/message/text.py
class Text(Message):
    """Inherits from Message class.

    Inherits from Message class, represents a Text Message api object.

    Args:
        body: Message body text.
        preview_url: Must be set to true, when you want to render the embed for the url in the body.
    """

    def __init__(
        self,
        body: str,
        preview_url: bool = False,
        to: str = None,
    ) -> None:
        self.body = body
        self.preview_url = preview_url

        super().__init__(to=to)

    def set_body(self, body: str):
        """Sets the body value.

        Args:
            body: Message body text.
        """
        self.body = body

    def preview_url(self, _state: bool = None):
        """Toggles the preview url state

        Args:
            _state: New preview_url state.
        """

        if _state is None:
            self.preview_url = not self.preview_url

        self.preview_url = _state

preview_url(_state=None)

Toggles the preview url state

Parameters:

Name Type Description Default
_state bool

New preview_url state.

None
Source code in whatsapie/ext/message/text.py
def preview_url(self, _state: bool = None):
    """Toggles the preview url state

    Args:
        _state: New preview_url state.
    """

    if _state is None:
        self.preview_url = not self.preview_url

    self.preview_url = _state

set_body(body)

Sets the body value.

Parameters:

Name Type Description Default
body str

Message body text.

required
Source code in whatsapie/ext/message/text.py
def set_body(self, body: str):
    """Sets the body value.

    Args:
        body: Message body text.
    """
    self.body = body