Skip to content

Commit ac08452

Browse files
authored
Merge pull request #477 from Gasol/quote-messages
Add quote message property to message types
2 parents e6d67e2 + d24c66f commit ac08452

File tree

2 files changed

+72
-43
lines changed

2 files changed

+72
-43
lines changed

lib/types.ts

Lines changed: 70 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,12 @@ export type TextEventMessage = {
429429
userId?: string;
430430
}[];
431431
};
432-
} & EventMessageBase;
432+
/**
433+
* Message ID of a quoted message. Only included when the received message quotes a past message.
434+
*/
435+
quotedMessageId?: string;
436+
} & QuotableMessage &
437+
EventMessageBase;
433438

434439
export type ContentProvider<WithPreview extends boolean = true> =
435440
| {
@@ -486,7 +491,8 @@ export type ImageEventMessage = {
486491
*/
487492
total: number;
488493
};
489-
} & EventMessageBase;
494+
} & QuotableMessage &
495+
EventMessageBase;
490496

491497
/**
492498
* Message object which contains the video content sent from the source.
@@ -495,7 +501,8 @@ export type ImageEventMessage = {
495501
export type VideoEventMessage = {
496502
type: "video";
497503
contentProvider: ContentProvider;
498-
} & EventMessageBase;
504+
} & QuotableMessage &
505+
EventMessageBase;
499506

500507
/**
501508
* Message object which contains the audio content sent from the source.
@@ -552,7 +559,12 @@ export type StickerEventMessage = {
552559
* Max character limit: 100
553560
*/
554561
text?: string;
555-
} & EventMessageBase;
562+
/**
563+
* Message ID of a quoted message. Only included when the received message quotes a past message.
564+
*/
565+
quotedMessageId?: string;
566+
} & QuotableMessage &
567+
EventMessageBase;
556568

557569
export type Postback = {
558570
data: string;
@@ -632,35 +644,50 @@ export type MessageCommon = {
632644
sender?: Sender;
633645
};
634646

635-
/**
636-
* @see [Text message](https://developers.line.biz/en/reference/messaging-api/#text-message)
637-
*/
638-
export type TextMessage = MessageCommon & {
639-
type: "text";
647+
type QuotableMessage = {
640648
/**
641-
* Message text. You can include the following emoji:
642-
*
643-
* - LINE emojis. Use a $ character as a placeholder and specify the product ID and emoji ID of the LINE emoji you want to use in the emojis property.
644-
* - Unicode emoji
645-
* - (Deprecated) LINE original unicode emojis
646-
* ([Unicode codepoint table for LINE original emoji](https://developers.line.biz/media/messaging-api/emoji-list.pdf))
647-
*
648-
* Max: 5000 characters
649+
* Quote token to quote this message.
649650
*/
650-
text: string;
651+
quoteToken: string;
652+
};
651653

654+
type CanQuoteMessage = {
652655
/**
653-
* One or more LINE emoji.
654-
*
655-
* Max: 20 LINE emoji
656+
* Quote token of the message you want to quote.
656657
*/
657-
emojis?: {
658-
index: number;
659-
productId: string;
660-
emojiId: string;
661-
}[];
658+
quoteText?: string;
662659
};
663660

661+
/**
662+
* @see [Text message](https://developers.line.biz/en/reference/messaging-api/#text-message)
663+
*/
664+
export type TextMessage = MessageCommon &
665+
CanQuoteMessage & {
666+
type: "text";
667+
/**
668+
* Message text. You can include the following emoji:
669+
*
670+
* - LINE emojis. Use a $ character as a placeholder and specify the product ID and emoji ID of the LINE emoji you want to use in the emojis property.
671+
* - Unicode emoji
672+
* - (Deprecated) LINE original unicode emojis
673+
* ([Unicode codepoint table for LINE original emoji](https://developers.line.biz/media/messaging-api/emoji-list.pdf))
674+
*
675+
* Max: 5000 characters
676+
*/
677+
text: string;
678+
679+
/**
680+
* One or more LINE emoji.
681+
*
682+
* Max: 20 LINE emoji
683+
*/
684+
emojis?: {
685+
index: number;
686+
productId: string;
687+
emojiId: string;
688+
}[];
689+
};
690+
664691
/**
665692
* @see [Image message](https://developers.line.biz/en/reference/messaging-api/#image-message)
666693
*/
@@ -753,22 +780,23 @@ export type LocationMessage = MessageCommon & {
753780
/**
754781
* @see [Sticker message](https://developers.line.biz/en/reference/messaging-api/#sticker-message)
755782
*/
756-
export type StickerMessage = MessageCommon & {
757-
type: "sticker";
758-
/**
759-
* Package ID for a set of stickers.
760-
* For information on package IDs, see the
761-
* [Sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
762-
*/
763-
packageId: string;
764-
/**
765-
* Sticker ID.
766-
* For a list of sticker IDs for stickers that can be sent with the Messaging
767-
* API, see the
768-
* [Sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
769-
*/
770-
stickerId: string;
771-
};
783+
export type StickerMessage = MessageCommon &
784+
CanQuoteMessage & {
785+
type: "sticker";
786+
/**
787+
* Package ID for a set of stickers.
788+
* For information on package IDs, see the
789+
* [Sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
790+
*/
791+
packageId: string;
792+
/**
793+
* Sticker ID.
794+
* For a list of sticker IDs for stickers that can be sent with the Messaging
795+
* API, see the
796+
* [Sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
797+
*/
798+
stickerId: string;
799+
};
772800

773801
/**
774802
* @see [Imagemap message](https://developers.line.biz/en/reference/messaging-api/#imagemap-message)

test/middleware.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ describe("middleware", () => {
1919
message: {
2020
id: "test_event_message_id",
2121
text: "this is test message.😄😅😢😞😄😅😢😞",
22+
quoteToken: "test_quote_token",
2223
type: "text",
2324
},
2425
replyToken: "test_reply_token",
@@ -35,7 +36,7 @@ describe("middleware", () => {
3536
type: "message",
3637
};
3738
const webhookSignature = {
38-
"X-Line-Signature": "Ey7AjSuSI2GfTDQHICAiRLLJ+GSMseISNYaQ6qXSjrU=",
39+
"X-Line-Signature": "eRdWYcVCzZV3MVZ3M9/rHJCl/a3oSbsRb04cLovpVwM=",
3940
};
4041

4142
const http = (headers: any = { ...webhookSignature }) =>

0 commit comments

Comments
 (0)