boybundit / linebot

🤖 SDK for the LINE Messaging API for Node.js
https://www.npmjs.com/package/linebot
MIT License
216 stars 93 forks source link

Support LINE text message with emoji #45

Closed hearsilent closed 4 years ago

hearsilent commented 4 years ago

@boybundit Please review this 🙏

boybundit commented 4 years ago

@hearsilent I don't yet see any benefit adding emojis as arguments because ones can construct the json message structure they want and just pass the message object. Perhaps we can help populate the index parameter?

I think it would be better if we offer easier way to send emoji. For example:


// Users define frequently used emojis in our chosen format e.g. {{emoji/productId/emojiId}}
const EMOJI_HEART_EYES = '{{emoji/5ac1bfd5040ab15980c9b435/001}}';
const EMOJI_CLOSED_EYES_SMILE = '{{emoji/5ac1bfd5040ab15980c9b435/001}}';

// Users insert emoji into plain text reply
event.reply(`${EMOJI_HEART_EYES} LINE emoji ${EMOJI_CLOSED_EYES_SMILE}`);

And linebot will convert the text into correct text object with emojis array.

{
    "type": "text",
    "text": "$ LINE emoji $",
    "emojis": [
      {
        "index": 0,
        "productId": "5ac1bfd5040ab15980c9b435",
        "emojiId": "001"
      },
      {
        "index": 13,
        "productId": "5ac1bfd5040ab15980c9b435",
        "emojiId": "002"
      }
    ]
}
hearsilent commented 4 years ago

@boybundit You're right! The origin code can put full object to support emojis, this PR is unnecessary.

I'll try to support this

event.reply(`${EMOJI_HEART_EYES} LINE emoji ${EMOJI_CLOSED_EYES_SMILE}`);

If I've time 😅

Thx for suggestions!