Skip to content

Emoji is not supported by linebot.models.TextSendMessage #297

@hylom

Description

@hylom

I want to use LINE emoji in Text message (https://developers.line.biz/en/reference/messaging-api/#text-message), but current linebot.models.TextSendMessage does not support emojis.

System Informations

  • Python version: 3.8.5
  • SDK version: 1.17.0
  • OS: macOS 10.15.7

Expected Behavior

linebot.models.TextSendMessage() accepts emojis parameter

Current Behavior

linebot.models.TextSendMessage() ignores emojis parameter

Steps to Reproduce

>>> import linebot.models
>>> emoji = {"index": 0, "productId": "5ac1bfd5040ab15980c9b435", "emojiId": "001"}
>>> m = linebot.models.TextSendMessage(text="$foo", emojis=[emoji])
>>> print(m)
{"text": "$foo", "type": "text"}

I think this can be achieved easily with change linebot.models.TextSendMessage like this:

class TextSendMessage(SendMessage):
    """TextSendMessage.
    https://developers.line.biz/en/reference/messaging-api/#text-message
    """

    def __init__(self, text=None, emojis=None, quick_reply=None, **kwargs):
        """__init__ method.
        :param str text: Message text
        :param List emojis: Array of LINE emoji objects
        :param quick_reply: QuickReply object
        :type quick_reply: T <= :py:class:`linebot.models.send_messages.QuickReply`
        :param kwargs:
        """
        super(TextSendMessage, self).__init__(quick_reply=quick_reply, **kwargs)

        self.type = 'text'
        self.text = text

        # ADD BELOW LINES
        if emojis:
            new_emojis = []
            for emoji in emojis:
                emoji_object = self.get_or_new_from_json_dict(
                    emoji, Emojis
                )
                if emoji_object:
                    new_emojis.append(emoji_object)
            self.emojis = new_emojis
        self.emojis = emojis

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions