@@ -3,14 +3,24 @@ import type { messagingApi } from "@line/bot-sdk";
33import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime" ;
44
55export type Action = messagingApi . Action ;
6+ export const LINE_ACTION_LABEL_LIMIT = 20 ;
7+ export const LINE_ACTION_DATA_LIMIT = 300 ;
8+
9+ export function truncateLineActionLabel ( label : string , limit = LINE_ACTION_LABEL_LIMIT ) : string {
10+ return truncateUtf16Safe ( label , limit ) ;
11+ }
12+
13+ export function truncateLineActionData ( data : string ) : string {
14+ return truncateUtf16Safe ( data , LINE_ACTION_DATA_LIMIT ) ;
15+ }
616
717/**
818 * Create a message action (sends text when tapped)
919 */
1020export function messageAction ( label : string , text ?: string ) : Action {
1121 return {
1222 type : "message" ,
13- label : truncateUtf16Safe ( label , 20 ) ,
23+ label : truncateLineActionLabel ( label ) ,
1424 text : text ?? label ,
1525 } ;
1626}
@@ -21,7 +31,7 @@ export function messageAction(label: string, text?: string): Action {
2131export function uriAction ( label : string , uri : string ) : Action {
2232 return {
2333 type : "uri" ,
24- label : truncateUtf16Safe ( label , 20 ) ,
34+ label : truncateLineActionLabel ( label ) ,
2535 uri,
2636 } ;
2737}
@@ -32,9 +42,9 @@ export function uriAction(label: string, uri: string): Action {
3242export function postbackAction ( label : string , data : string , displayText ?: string ) : Action {
3343 return {
3444 type : "postback" ,
35- label : truncateUtf16Safe ( label , 20 ) ,
36- data : truncateUtf16Safe ( data , 300 ) ,
37- displayText : displayText === undefined ? undefined : truncateUtf16Safe ( displayText , 300 ) ,
45+ label : truncateLineActionLabel ( label ) ,
46+ data : truncateLineActionData ( data ) ,
47+ displayText : displayText === undefined ? undefined : truncateLineActionData ( displayText ) ,
3848 } ;
3949}
4050
@@ -53,8 +63,8 @@ export function datetimePickerAction(
5363) : Action {
5464 return {
5565 type : "datetimepicker" ,
56- label : truncateUtf16Safe ( label , 20 ) ,
57- data : truncateUtf16Safe ( data , 300 ) ,
66+ label : truncateLineActionLabel ( label ) ,
67+ data : truncateLineActionData ( data ) ,
5868 mode,
5969 initial : options ?. initial ,
6070 max : options ?. max ,
0 commit comments